This article shares an example of C# implementation of SMS verification code interface for your reference. The specific content is as follows
using System; using ; using ; using ; using ; using .X509Certificates; using ; using ; using ; using ; using ; using ; public class Test { private static readonly string DefaultUserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"; private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) { return true; //Always accept } static void Main(string[] args) { DateTime dt = ; string mttime = ("yyyyMMddHHmmss"); string pwd1 = "*************"+mttime; string pwd = GetMD5(pwd1) string content = "【Reading Letter】Verification code 888888, you can't tell others even if you beat me to death."; string url = "http://183.203.28.226:9000/HttpSmsMt"; Encoding encoding = ("utf-8"); IDictionary<string, string> parameters = new Dictionary<string, string>(); ("name", "****"); ("pwd", pwd); ("content",content); ("phone","13381272353"); ("subid",""); ("mttime", mttime); HttpWebResponse response = CreatePostHttpResponse(url,parameters,encoding); //Print return value Stream stream = (); //Get the response string stream StreamReader sr = new StreamReader(stream); //Create a stream read stream string html = (); //Read from beginning to end and put it into the string html (html); } public static string GetMD5(string myString) { MD5 md5 = new MD5CryptoServiceProvider(); // byte[] fromData = (myString); byte[] fromData = (myString); byte[] targetData = (fromData); string byte2String = null; for(int i=0;i<;i++) { byte2String+= targetData[i].ToString("x"); } return byte2String; } public static HttpWebResponse CreatePostHttpResponse(string url, IDictionary<string, string> parameters,Encoding charset) { HttpWebRequest request = null; //HTTPS request = new RemoteCertificateValidationCallback(CheckValidationResult); request = (url) as HttpWebRequest; = HttpVersion.Version10; = "POST"; = "application/x-www-form-urlencoded"; = DefaultUserAgent; //If POST data is required if (!(parameters == null || == 0)) { StringBuilder buffer = new StringBuilder(); int i = 0; foreach (string key in ) { if (i > 0) { ("&{0}={1}", key, parameters[key]); } else { ("{0}={1}", key, parameters[key]); } i++; } byte[] data = (()); using (Stream stream = ()) { (data, 0, ); } } return () as HttpWebResponse; } }
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.