復制代碼 代碼如下:
Dim postData As String
Dim byteArray As Byte()
Dim objWebRequest As HttpWebRequest
Dim newStream As Stream
postData = "cell=短信供應商提供信息1&enterpriseId=短信供應商提供信息2&mobile=手機號1,手機號2&message=發送數據測試。。。"
objWebRequest = WebRequest.Create("http://xxx.yyy.com.cn/SmsSend.jsp")
objWebRequest.Method = "POST"
objWebRequest.ContentType = "application/x-www-form-urlencoded"
byteArray = System.Text.Encoding.UTF8.GetBytes(postData)
objWebRequest.ContentLength = byteArray.Length
newStream = objWebRequest.GetRequestStream()
newStream.Write(byteArray, 0, byteArray.Length)
newStream.Close()
'返回數據
Dim response As HttpWebResponse
Dim sr As StreamReader
Dim textResponse As String
response = objWebRequest.GetResponse()
sr = New StreamReader(response.GetResponseStream(), System.Text.Encoding.Default)
textResponse = sr.ReadToEnd()