短信营销 - 代码示例 * * * * * [[PHP](sms/PHP.md)][[JAVA](sms/JAVA.md)][[ASP](sms/ASP.md) [[ASP.NET(C#)](sms/ASPNET.md)][[JSP](sms/JSP.md)][[C](sms/C.md)][[C++](sms/C++.md)][[GO](sms/GO.md)][[PYTHON](sms/PYTHON.md)][[VB6](sms/VB6.md)] VB6代码示例 ~~~ ' 接口类型:企讯云营销短信接口,支持发送会员营销短信。 ' 接口地址:http://service.qixunpush.com/sendSMS ' 账户注册:请联系客服开通账户 ' 注意事项: '(1)调试期间,请仔细阅读接口文档; '(2)请使用 account 及 password 来调用接口,可联系客服获取; '(3)该代码仅供接入企讯云短信接口参考使用,客户可根据实际需要自行编写; Private Sub Form_Load() Winsock1.Protocol = sckTCPProtocol Winsock1.RemoteHost = "service.qixunpush.com" Winsock1.RemotePort = 80 Winsock1.Connect DoEvents If Winsock1.State <> 7 Then Label1.Caption = "状态:服务器连接成功" & Chr(13) '用户名 和 密码 请联系客服获取 Text1.Text = "用户名" Text2.Text = "密码" '手机号码,多个号码请用,隔开 Text3.Text = "139xxxxxxxx" Text4.Text = "【企讯云】尊敬的会员,您好!新品上市,全场3折起!敬请关注。退订回TD" 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 /sendSMS 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.yx.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://service.qixunpush.com/sendSMS" + 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 If Winsock1.State <> 7 Then Winsock1.Protocol = sckTCPProtocol Winsock1.RemoteHost = "service.qixunpush.com" Winsock1.RemotePort = 80 Winsock1.Connect DoEvents Winsock1.SendData Str Else Winsock1.SendData strCommand End If End Sub Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) Dim rec() As Byte Winsock1.GetData rec, vbString Label2.Visible = True Label2.Caption = Utf8ToUnicode(rec) Winsock1.Close End Sub ~~~