VB6怎样运行一个短信发布功能,采用HTTP方式
1个回答
展开全部
Function GetByWinHttp$(ByVal GetUrl$)
On Error Resume Next
Dim XmlHttp As Object
'Dim PicBytes() As Byte '验证码字节数组
Set XmlHttp = CreateObject("WinHttp.WinHttpRequest.5.1")
With XmlHttp
'.SetProxy 2, "IP:Port" '设置代理
If InStr(GetUrl, "&__K") <> 0 Then .Option(6) = False '禁止重定向
.Open "GET", GetUrl, True
.SetRequestHeader "Accept", "image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, application/QVOD, application/QVOD, */*"
.SetRequestHeader "Accept-Language", "zh-cn"
.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)"
'.SetRequestHeader "Accept-Encoding","gzip, deflate" 'gzip为压缩格式,一般可注释此行,如获取不到页面内容,或许就需要解压了.
'.SetRequestHeader "Host","bb" '一般可以省略。
.SetRequestHeader "Connection", "Keep-Alive"
.Send
.WaitForResponse
' PicBytes = .ResponseBody '下载后加载验证码
' Open App.Path & "\VerCode.jpg" For Binary As #1
' Put #1, , PicBytes
' Close #1
' frmMain.Picture1.Picture = LoadPicture(App.Path & "\VerCode.jpg")
' Kill App.Path & "\VerCode.jpg"
'========================================================'直接加载验证码[需加载ModLoadPngPic.Bas模块]
' Dim m_token As Long
' Dim StartupInput As GdiplusStartupInput
' StartupInput.GdiplusVersion = 1
' If GdiplusStartup(m_token, StartupInput, ByVal 0&) Then
' MsgBox "Error initializing GDI+"
' Exit Function
On Error Resume Next
Dim XmlHttp As Object
'Dim PicBytes() As Byte '验证码字节数组
Set XmlHttp = CreateObject("WinHttp.WinHttpRequest.5.1")
With XmlHttp
'.SetProxy 2, "IP:Port" '设置代理
If InStr(GetUrl, "&__K") <> 0 Then .Option(6) = False '禁止重定向
.Open "GET", GetUrl, True
.SetRequestHeader "Accept", "image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, application/QVOD, application/QVOD, */*"
.SetRequestHeader "Accept-Language", "zh-cn"
.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)"
'.SetRequestHeader "Accept-Encoding","gzip, deflate" 'gzip为压缩格式,一般可注释此行,如获取不到页面内容,或许就需要解压了.
'.SetRequestHeader "Host","bb" '一般可以省略。
.SetRequestHeader "Connection", "Keep-Alive"
.Send
.WaitForResponse
' PicBytes = .ResponseBody '下载后加载验证码
' Open App.Path & "\VerCode.jpg" For Binary As #1
' Put #1, , PicBytes
' Close #1
' frmMain.Picture1.Picture = LoadPicture(App.Path & "\VerCode.jpg")
' Kill App.Path & "\VerCode.jpg"
'========================================================'直接加载验证码[需加载ModLoadPngPic.Bas模块]
' Dim m_token As Long
' Dim StartupInput As GdiplusStartupInput
' StartupInput.GdiplusVersion = 1
' If GdiplusStartup(m_token, StartupInput, ByVal 0&) Then
' MsgBox "Error initializing GDI+"
' Exit Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询