國內短信接口權威運營服務商網    電信全網移動信息服務許可證:B2-20150469

7x24小時服務熱線:

400-113-0919

VB.NET接口示例

Module SendEsms

Sub Main()
Dim strContent As String = "測試"
Dim uid As String = "test"
Dim pwd As String = "fa246d0262c3925617b0c72bb20eeb1d"
Dim mobile As String = "15900001111,13900001111"
'GET 方式
Dim getReturn As String = doGetRequest("http://api.sms.cn/sms/?ac=send&uid="+uid+"&pwd="+pwd+"&mobile="+mobile+"&content=" + strContent)
Console.WriteLine("Get response is: " & getReturn)

'POST 方式
Dim sbTemp As System.Text.StringBuilder = New System.Text.StringBuilder()
sbTemp.Append("ac=send&uid="+uid+"&pwd="+pwd+"&mobile="+mobile+"&content=" + strContent)
Dim bTemp() As Byte = System.Text.Encoding.GetEncoding("GBK").GetBytes(sbTemp.ToString())
Dim postReturn As String = doPostRequest("http://api.sms.cn/sms/", bTemp)
Console.WriteLine("Post response is: " + postReturn)


End Sub

'發送HTTP GET請求得結果
Private Function doGetRequest(ByVal url As String) As String
Dim strReturn As String = ""
Dim hwRequest As System.Net.HttpWebRequest
Dim hwResponse As System.Net.HttpWebResponse
Try
hwRequest = System.Net.HttpWebRequest.Create(url)
hwRequest.Timeout = 5000
hwRequest.Method = "GET"
hwRequest.ContentType = "application/x-www-form-urlencoded"

hwResponse = hwRequest.GetResponse()
Dim srReader As System.IO.StreamReader = New System.IO.StreamReader(hwResponse.GetResponseStream(), System.Text.Encoding.ASCII)
strReturn = srReader.ReadToEnd()
srReader.Close()
hwResponse.Close()

Catch
End Try
Return strReturn
End Function

'發送HTTP POST請求得結果
Private Function doPostRequest(ByVal url As String, ByVal bData() As Byte) As String
Dim strReturn As String = ""
Dim hwRequest As System.Net.HttpWebRequest
Dim hwResponse As System.Net.HttpWebResponse
Try
hwRequest = System.Net.HttpWebRequest.Create(url)
hwRequest.Timeout = 5000
hwRequest.Method = "POST"
hwRequest.ContentType = "application/x-www-form-urlencoded"
hwRequest.ContentLength = bData.Length

Dim smWrite As System.IO.Stream = hwRequest.GetRequestStream()
smWrite.Write(bData, 0, bData.Length)
smWrite.Close()

hwResponse = hwRequest.GetResponse()
Dim srReader As System.IO.StreamReader = New System.IO.StreamReader(hwResponse.GetResponseStream(), System.Text.Encoding.ASCII)
strReturn = srReader.ReadToEnd()
srReader.Close()
hwResponse.Close()
Catch

End Try
Return strReturn
End Function

End Module

 

 


VB.NET短信接口示例
(*^▽^*)MG凯蒂卡巴拉技巧介绍 广东快乐10分人工计划 qq南昌麻将 三d彩票历史开奖号码查询结果 高频彩倍投计算器哪个好 河南快赢481走势 彩票快乐12开奖 英国莱特币矿机 重庆老时时彩走适图 北京快乐8人工计划网站 黑龙江11选5开奖视频 2013国庆股票交易放假 欢乐捕鱼人金龙鱼 北京扑克麻将 足球彩票手机软件官方 高频彩票为什么一定输 安徽11选5任选5单试票