VB6語言對(duì)接三方短信接口demo示例
//接口類型:互億無線觸發(fā)短信接口鸠匀,支持發(fā)送驗(yàn)證碼短信蕉斜、訂單通知短信等。
//賬戶注冊(cè):請(qǐng)通過該地址開通賬戶?http://user.ihuyi.com/?DKimmu
//注意事項(xiàng):
//(1)調(diào)試期間缀棍,請(qǐng)使用用系統(tǒng)默認(rèn)的短信內(nèi)容:您的驗(yàn)證碼是:【變量】宅此。請(qǐng)不要把驗(yàn)證碼泄露給其他人。
//(2)請(qǐng)使用 用戶名 及 APIkey來調(diào)用接口爬范,APIkey在會(huì)員中心可以獲雀竿蟆;
//(3)該代碼僅供接入互億無線短信接口參考使用青瀑,客戶可根據(jù)實(shí)際需要自行編寫璧亮;
Private Sub Form_Load()
Winsock1.Protocol = sckTCPProtocol
Winsock1.RemoteHost = "http://106.ihuyi.com"
Winsock1.RemotePort = 80
Winsock1.Connect
DoEvents
If Winsock1.State <> 7 Then Label1.Caption = "狀態(tài):服務(wù)器連接成功" & Chr(13)
Text1.Text = "用戶名"
Text2.Text = "密碼可以使用明文密碼或使用32位MD5加密"
Text3.Text = "手機(jī)號(hào)碼&coding=GBK" '&coding=GBK不要?jiǎng)h除
End Sub
Private Sub Command1_Click()
On Error Resume Next
Dim PostData As String
Dim Str As String
Dim strWebPage As String
Dim strCommand As String
PostData = "account=" + Text1.Text + "&password=" + Text2.Text + "&mobile=" + Text3.Text + "&content=" + Text4.Text
Dim Ai() As Byte
Ai = StrConv(strWebPage, vbFromUnicode)
CLength = UBound(Ai) + 1
Str = "POST /webservice/sms.php?method=Submit HTTP/1.1" + vbCrLf
Str = Str + "Accept: */*" + vbCrLf
Str = Str + "Content-Type: application/x-www-form-urlencoded" + vbCrLf
Str = Str + "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; Maxthon; .NET CLR 1.1.4322)" & vbCrLf
Str = Str + "Language: zh-CN, zh, *" + vbCrLf
Str = Str + "Connection: Keep-Alive" + vbCrLf
Str = Str + "Host:?http://106.ihuyi.com" + vbCrLf
Str = Str + "Accept-Language: zh-CN, zh, *" + vbCrLf
Str = Str + "Accept-Encoding: gzip, deflate" & vbCrLf
Str = Str & "Content-Length: " & Len(PostData) & vbCrLf & vbCrLf
Str = Str & PostData & vbCrLf
'MsgBox str
strWebPage = "http://106.ihuyi.com/webservice/sms.php?method=Submit&account=" + Text1.Text + "&password=" + Text2.Text + "&mobile=" + Text3.Text + "&content=" + Text4.Text
strCommand = "GET " + strWebPage + " HTTP/1.0" + vbCrLf
strCommand = strCommand + vbCrLf
If Winsock1.State <> 7 Then
Winsock1.Protocol = sckTCPProtocol
Winsock1.RemoteHost = "http://106.ihuyi.com"
Winsock1.RemotePort = 80
Winsock1.Connect
DoEvents
Winsock1.SendData Str
Else
Winsock1.SendData strCommand
End If
'Label1.Caption = "狀態(tài):" & strState & Chr(13) & strCommand & Chr(13)
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim rec() As Byte
Winsock1.GetData rec, vbString
'MsgBox Utf8ToUnicode(Right(rec, 150))
Label2.Visible = True
Label2.Caption = Utf8ToUnicode(rec)
Winsock1.Close
End Sub