namespacesendsms{classProgram {Static voidMain (string[] args) { stringPhone ="13770504xxxx"; stringSign =string. Format ("" " Your verification code is {0} and this code is valid for 10 minutes","1234"); BOOLresult =sendmsg (phone,sign); } Public Static BOOLSendmsg (stringPhonestringcontent) { varSmsurl ="*****"; varAccount ="****"; varPWD ="****"; varExtno ="****"; varresult = HttpPost (Smsurl,"&account="+ account +"&password="+ pwd +"&mobile="+ Phone +"&content="+ httputility.urlencode (content, Encoding.UTF8) +"&extno="+Extno); if(result.) IndexOf ("OK") >-1) { return true; } return false; } Public Static stringHttpPost (stringUrlstringpostdatastr) { byte[] bs =Encoding.UTF8.GetBytes (POSTDATASTR); HttpWebRequest req=(HttpWebRequest) httpwebrequest.create (URL); Req. Method="POST"; Req. ContentType="application/x-www-form-urlencoded"; Req. ContentLength=BS. Length; using(Stream Reqstream =req. GetRequestStream ()) {Reqstream.write (BS,0, BS. Length); } using(WebResponse WR =req. GetResponse ()) {StreamReader SR=NewStreamReader (WR. GetResponseStream (), System.Text.Encoding.UTF8); stringresult =Sr. ReadToEnd (); returnresult; } } }}
. NET using HttpWebRequest to send phone verification code