have been using this platform to send mobile phone messages, today to do new projects when used, but up to the blog search, had to turn over the previous source code for a long time to find, first write down, to make standby:
Using System;
Using System.Collections.Generic;
Using System.IO;
Using System.Linq;
Using System.Net;
Using System.Text;
Using System.Web;
Namespace Niunan.CardShop.Web.Code
{
public class Sendmobile
{
<summary> return status instructions for sending SMS
///
</summary>
<param name= "str" ></param>
<returns></returns>
public static string Getmobilemsmstatus (String str)
{
string s = "";
Switch (STR)
{
Case "-1":
s = "No such user account";
Break
Case "-2":
s = "key is incorrect (not user password)";
Break
Case "-3":
s = "Insufficient number of SMS";
Break
Case "-11":
s = "The user is disabled";
Break
Case "-14":
s = "Illegal characters appear in SMS Content";
Break
Case "-4":
s = "Phone number format is incorrect";
Break
Case "-41":
s = "mobile phone number is empty";
Break
Case "-42":
s = "SMS content is empty";
Break
Default
s = "Send successfully" + str + "text message";
Break
}
return s;
}
<summary> Send SMS
///
</summary>
<param name= "mobile" > Mobile phone number, multiple mobile phone number, number separated by </param>
<param name= "Body" > SMS Content </param>
public static string Sendmobilemsm (string mobile, string body)
{
String url = "http://utf8.sms.webchinese.cn/?Uid=xxxxxx&Key=xxxxxx&smsMob=" + Mobile + "&smstext=" + body;
String targeturl = URL. Trim (). ToString ();
Try
{
HttpWebRequest hr = (HttpWebRequest) webrequest.create (TargetUrl);
hr. useragent = "mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) ";
hr. Method = "GET";
hr. Timeout = 30 * 60 * 1000;
WebResponse hs = hr. GetResponse ();
Stream sr = HS. GetResponseStream ();
StreamReader ser = new StreamReader (SR, Encoding.default);
Return Getmobilemsmstatus (Ser. ReadToEnd ());
}
catch (Exception ex)
{
Throw ex;
}
}
}
}
C # code for texting on a "web-built" platform