C#个性化短信群发接口 代码示例


提醒:如果Encoding.Default不是 UTF8,请直接使用 UTF8

C#个性化短信群发接口示例

请求
string mobile = "<enter your mobiles>",
cid = "<enter your cid>",
uid = "<enter your UID>",
pas = "<enter your UID Pass>",
data = "<enter your UID Data>",
url = "http://api.weimi.cc/2/sms/batch.html"; 
byte[] byteArray = Encoding.UTF8.GetBytes("mob=" + mobile + "&cid=" + cid + "&uid=" + uid + "&pas=" + pas + "&data=" + data + "&type=json");
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(new Uri(url));
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.ContentLength = byteArray.Length;
Stream newStream = webRequest.GetRequestStream();
newStream.Write(byteArray, 0, byteArray.Length);
newStream.Close();
HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
StreamReader php = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
string Message = php.ReadToEnd();
System.Console.Write(Message);
System.Console.Read();
/*
注意:以上参数传入时不包括“<>”符号
*/

 

返回结果
{ "code":0, "msg":"发送成功" }

 


请参考

√ 开发文档

√ 短信接口

√ 彩信接口

√ 账户余额查询接口

√ PHP示例

√ Java示例

√ Python示例

√ Node.js示例

 

下载文档 | Java示例源代码 | PHP示例源代码 | 我的微米 | 常见问题 | 微米使用流程 | 联系客服