如何使用web Api发送短信 [英] How can use web Api to send sms

查看:105
本文介绍了如何使用web Api发送短信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Web Api从我的网站发送短信

并使用此代码但可能无法正常工作。





I want to use Web Api to send sms from my website
and use this code but not work probably.


string Username ="My username";
    string Password ="My password";
    string TO ="mobile number";
    string TEXT = "some text";
    string sURL;
    StreamReader objReader;
    sURL = "http://ars-sms.ir/API/SendSMS.asmx?Username='" + Username + "@Password=" + Password + "@TO" + TO + "@TEXT" + TEXT;
    WebRequest wrGETURL;
    wrGETURL = WebRequest.Create(sURL);
    try
    {
        Stream objStream;
        objStream = wrGETURL.GetResponse().GetResponseStream();
        objReader = new StreamReader(objStream);
        objReader.Close();
    }
    catch (Exception ex)
    {
        ex.ToString();
    }



我的代码有什么问题吗?


Is there any problem with my code?

推荐答案

Are你确定下面的行是正确的吗?

Are you sure the below line is correct?
sURL = "http://ars-sms.ir/API/SendSMS.asmx?Username='" + Username + "@Password=" + Password + "@TO" + TO + "@TEXT" + TEXT;



1你能用HTTP GET调用服务吗?

2.为什么在Username变量之前有一个单引号?这真的需要吗?

3.为什么使用@字符分隔参数?这是ars-sms.ir网站要求的吗?通常你会使用&字符。

4.我没有在TO和TEXT参数的关键字和值之间看到=字符。



如果你不知道为什么或对上述问题有答案你可能想尝试用下面的代替你的网址...


1. Can you call the service using HTTP GET?
2. Why do you have a single quote before the Username variable? Is this really needed?
3. Why are you using the @ character to separate your parameters? Is this required by the ars-sms.ir site? Normally you would use the & character.
4. I don't see an = character between the keyword and value for the TO and TEXT parameters.

If you don't know why or have an answer to the above questions you may want to try replacing your URL with the below...

sURL = "http://ars-sms.ir/API/SendSMS.asmx?Username=" + Username + "&Password=" + Password + "&TO=" + TO + "&TEXT=" + TEXT;


这篇关于如何使用web Api发送短信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆