First of all, I used C # to implement the first method, and found that it was always wrong. This puzzled me. Later, I looked up the reasons from the Internet. Some said that the function of Sina was no longer used. I was not sure, so I gave up this method.
Later, the third method was implemented.
The concrete realization is as follows:
1. From the Internet( http://sms.webchinese.cn/ ) Apply for an account, remember the username, and the password will be sent to the mobile phone. This is just the login password. There are also short message secret keys, which we need to get. This is what we need to use later. We need to write our signatures in the secret keys. Also, we need to refer to the downlink interface parameters of the short message API for specific implementation.( http://sms.webchinese.cn/api.shtml There are various language implementations on this web page. I use C # to implement it. I am familiar with Java and can use java.
2. Now it can be programmed and implemented. This is also very simple. Reference to the C# implementation of the interface parameter web page can be done. Here is my example!
The interface is as follows:
Because the secret key is a little long, it's not entered here.
The code is as follows:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Net; using System.IO; namespace SendMsgSMS { public partial class Form1 : Form { private string url = "http://utf8.sms.webchinese.cn/?"; private string strUid = "Uid="; private string strKey = "&key=*******************"; //Here * stands for the secret key. Because it's a bit cumbersome from the beginning, it's not entered in the window. private string strMob = "&smsMob="; private string strContent = "&smsText="; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { if (txtUerName.Text.ToString().Trim() != "" && txtAttnNum.Text.ToString().Trim() != "" &&txtContent.Text.ToString() != null) { url = url + strUid + txtUerName.Text + strKey + strMob + txtAttnNum.Text + strContent + txtContent.Text; string Result = GetHtmlFromUrl(url); MessageBox.Show(Result); } } public string GetHtmlFromUrl(string url) { string strRet = null; if (url == null || url.Trim().ToString() == "") { return strRet; } 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); strRet = ser.ReadToEnd(); } catch (Exception ex) { strRet = null; } return strRet; } } }