跪求各位大虾帮忙翻译一下啊!

qq369777653 2012-11-06 11:57:33
各位大虾麻烦帮小弟翻译一下。
Sub PostGuestBook(ByVal strQQNumber As String, ByVal strCookies As String, ByVal Message As String)
Randomize
Dim strMessage As String
strMessage = "qzreferrer=http%3A%2F%2Fctc.qzs.qq.com%2Fqzone%2Fmsgboard%2Fmsgbcanvas.html%23uin%3D369777653%26pfid%3D2%26qz_ver%3D6%26appcanvas%3D0%26qz_style%3Dv6%2F31%26params%3D%26canvastype%3Dhome&content=" & Message & "&hostUin=" & strQQNumber & "&uin=" & getQQNumber(strCookies) & "&format=fs&g_tk=" & g_tkValue(strCookies) & "&ref=qzone&json=1&inCharset=gbk&outCharset=gbk&iNotice=1"
strUrl = "http://m.qzone.qq.com/cgi-bin/new/add_msgb?ref=qzone&g_tk=" & g_tkValue(strCookies)
Set XmlHttp = CreateObject("Msxml2.ServerXMLHTTP")
XmlHttp.Open "POST", strUrl, False
XmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
XmlHttp.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 2.0.50727)"
XmlHttp.setRequestHeader "Cookie", strCookies
XmlHttp.send (strMessage)
Dim ostm As Object: Set ostm = CreateObject("ADODB.Stream")
ostm.Open
ostm.Type = 1: ostm.Position = 0
ostm.Write XmlHttp.responsebody
ostm.Position = 0: ostm.Type = 2: ostm.Charset = "gb2312"
MsgBox ostm.readText(ostm.Size)
End Sub
...全文
445 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
luomingui 2014-02-12
  • 打赏
  • 举报
回复
总是提示请先登录。 public bool QzoneMessage(int qqnum, string message) { try { int gtk = GetGTK(this.skey); string num = txtQQNumber.Text.Trim(); WebClient _client = new WebClient(); string host = "http://m.qzone.qq.com/cgi-bin/new/add_msgb?ref=qzone&g_tk=" + gtk + ""; string postValues = "qzreferrer=http%3A%2F%2Fcnc.qzs.qq.com%2Fqzone%2Fmsgboard%2Fmsgbcanvas.html%23uin%3D123456%26pfid%3D2%26qz_ver%3D6%26appcanvas%3D0%26qz_style%3Dv6%2F18%26params%3D%26entertime%3D1356580709748%26canvastype%3D&content=" + message + "&hostUin=" + qqnum + "&uin=" + num + "&format=fs&g_tk=" + gtk + "&ref=qzone&json=1&inCharset=gbk&outCharset=gbk&iNotice=1"; byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(postValues); byte[] pageData = _client.UploadData(host, "POST", byteArray); string s = Encoding.Default.GetString(pageData); this.txtMessage.Text = s; return true; } catch (Exception) { return false; } }
c_cyd2008 2012-11-06
  • 打赏
  • 举报
回复

Sub PostGuestBook(ByVal strQQNumber As String, ByVal strCookies As String, ByVal Message As String)
    Randomize      '初始化随机函数种子,这东西在整个模块中没用
    Dim strMessage As String
    '拼接要提交的消息
    strMessage = "qzreferrer=http%3A%2F%2Fctc.qzs.qq.com%2Fqzone%2Fmsgboard%2Fmsgbcanvas.html%23uin%3D369777653%26pfid%3D2%26qz_ver%3D6%26appcanvas%3D0%26qz_style%3Dv6%2F31%26params%3D%26canvastype%3Dhome&content=" & Message & "&hostUin=" & strQQNumber & "&uin=" & getQQNumber(strCookies) & "&format=fs&g_tk=" & g_tkValue(strCookies) & "&ref=qzone&json=1&inCharset=gbk&outCharset=gbk&iNotice=1"
    
    '指定数据提交到什么地方
    strUrl = "http://m.qzone.qq.com/cgi-bin/new/add_msgb?ref=qzone&g_tk=" & g_tkValue(strCookies)
    
    '创建一个Msxml2.ServerXMLHTTP对象,用于向服务器提交和接收数据
    Set XmlHttp = CreateObject("Msxml2.ServerXMLHTTP")
    XmlHttp.Open "POST", strUrl, False    '先打开对象
    
    '设置请求头,具体涵义请看http协议
    XmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    XmlHttp.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 2.0.50727)"
    XmlHttp.setRequestHeader "Cookie", strCookies
    
    '提交数据
    XmlHttp.send (strMessage)
    
    '接收数据并处理
    Dim ostm As Object: Set ostm = CreateObject("ADODB.Stream")
    ostm.Open
    ostm.Type = 1: ostm.Position = 0
    ostm.Write XmlHttp.responsebody   '把收到的数据写入ostm中,想转换编码
    ostm.Position = 0: ostm.Type = 2: ostm.Charset = "gb2312"   '编码设为gb2312
    MsgBox ostm.readText(ostm.Size)
End Sub

东方之珠 2012-11-06
  • 打赏
  • 举报
回复
最好的办法是上机测试,设置断点,看程序执行的效果。

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧