VB6对接国际短信示例

Private Sub Form_Load()
    Winsock1.Protocol = sckTCPProtocol
    Winsock1.RemoteHost = "api.isms.ihuyi.com"
    Winsock1.RemotePort = 80
    Winsock1.Connect
    DoEvents
         
    If Winsock1.State <> 7 Then Label1.Caption = "状态:服务器连接成功" & Chr(13)
         
    Text1.Text = "用户名"
    Text2.Text = "密码为APIKEY(可以登录用户中心查看)"
    Text3.Text = "手机号码"
    Text4.Text = "Your verification code is 1125"
         
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=" + toUTF8(Text1.Text) + "&password=" + toUTF8(Text2.Text) + "&mobile=" + toUTF8(Text3.Text) + "&content=" + toUTF8(Text4.Text)
     
    Dim Ai() As Byte
    Ai = StrConv(strWebPage, vbFromUnicode)
    CLength = UBound(Ai) + 1
    Str = "POST /webservice/isms.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: api.isms.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
 
 
     
    strWebPage = "http://api.isms.ihuyi.com/webservice/isms.php?method=Submit&account=" + toUTF8(Text1.Text) + "&password=" + toUTF8(Text2.Text) + "&mobile=" + toUTF8(Text3.Text) + "&content=" + toUTF8(Text4.Text)
    strCommand = "GET " + strWebPage + " HTTP/1.0" + vbCrLf
    strCommand = strCommand + vbCrLf
     
    'MsgBox strWebPage
     
    If Winsock1.State <> 7 Then
        Winsock1.Protocol = sckTCPProtocol
        Winsock1.RemoteHost = "api.isms.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
账户申请地址:http://user.ihuyi.com/?AX7wLG

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值