码迷,mamicode.com
首页 > Windows程序 > 详细

weimi 短信API post方式的简易代码。

时间:2015-04-12 22:35:36      阅读:426      评论:0      收藏:0      [点我收藏+]

标签:

http://www.weimi.cc/example-csharp.html

string mobile = "<enter your mobiles>",
con = "【微米】您的验证码是:610912,3分钟内有效。如非您本人操作,可忽略本消息。",
uid = "<enter your UID>",
pas = "<enter your UID Pass>",
url = "http://api.weimi.cc/2/sms/send.html"; 
byte[] byteArray = Encoding.UTF8.GetBytes("mob=" + mobile + "&con=" + con + "&uid=" + uid + "&pas=" + pas + "&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.Default);
string Message = php.ReadToEnd();
System.Console.Write(Message);
System.Console.Read();

  学习post方式的简易代码。

weimi 短信API post方式的简易代码。

标签:

原文地址:http://www.cnblogs.com/shiratsuki/p/4420622.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!