using System; using System.Net; using System.IO; using System.Text; using System.Collections.Generic; using System.Threading; using System.Web; namespace QiRuiYun { class Program { private const string BASEURL = "http://api.qirui.com:7891/mt" ; static void Main( string [] args) { //APIKey(接口账号) String apiKey = "2288**0010" ; //APISecret(接口密钥) String apiSecret = "ae2600e9456f5b0b3ab8" ; //接受短信的手机号 String mobile = "15100000000" ; //短信内容(【签名】+短信内容),发送短信需要预先申请报备短信签名,控制台>接口短信>签名报备 String message = "【启瑞云】您的验证码是:5283" ; string template = "?dc=15&un={0}&pw={1}&da={2}&sm={3}&tf=3&rf=2&rd=0" ; string url = BASEURL + string .Format(template, apiKey, apiSecret, mobile, HttpUtility.UrlEncode(message, Encoding.UTF8)); //Console.WriteLine(url); var result = doRequest(url); Console.WriteLine(result); } static private String doRequest( string url) { string result; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "GET" ; HttpWebResponse response; try { response = (HttpWebResponse)request.GetResponse(); } catch (WebException ex) { response = (HttpWebResponse)ex.Response; } using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8)) { result = reader.ReadToEnd(); } return result; } } } |
√ 短信接口 :
1)短信内容一定要带签名,签名放在短信内容的最前面;
2)签名格式:【***】,签名内容为三个汉字以上(包括三个);
3)短信内容不允许双签名,即短信内容里只有一个"【】";
4)短信签名先申请报备后使用,控制台>接口短信>签名报备;