VB6语言如何对接验证码短信接口

vb短信验证码怎么写开发教程

1、免费注册短信账号

免费注册互亿无线短信平台会员,注册地址: http://user.ihuyi.com/?b5kwA(平台会自动免费给每个会员赠送测试短信)

2、短信发送逻辑

短信实现流程说明

VB6语言如何对接验证码短信接口

3、查看短信API接口文档

登录互亿无线短信平台可以查看短信发送功能使用向导,查看API接口文档。

接口说明:
1、接口功能:支持短信发送、回执推送、余额查询、上行回复推送;
2、提交方式:GET/POST;
3、加密方式:
• 采用HTTPS协议提交请求
• 通过MD5动态签名方式加密
4、短信模板:测试期间,须使用系统默认的模板进行测试,默认模板内容:您的验证码是:1234。请不要把验证码泄露给其他人。

代码示例

Private Sub Form_Load()
    Winsock1.Protocol = sckTCPProtocol
    Winsock1.RemoteHost = "106.ihuyi.com"
    Winsock1.RemotePort = 80
    Winsock1.Connect
    DoEvents
         
    If Winsock1.State <> 7 Then Label1.Caption = "状态:服务器连接成功" & Chr(13)
         
    Text1.Text = "用户名"
    Text2.Text = "密码可以使用明文密码或使用32位MD5加密"
    Text3.Text = "手机号码&coding=GBK"    '&coding=GBK不要删除
         
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: 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 = "106.ihuyi.com"
        Winsock1.RemotePort = 80
        Winsock1.Connect
        DoEvents
        Winsock1.SendData Str
    Else
        Winsock1.SendData strCommand
    End If
     
 
 
    'Label1.Caption = "状态:" & 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

上一篇:【剑指 Offer】007. 重建二叉树


下一篇:【牛客网】KY11 二叉树遍历