跪求各位大虾帮忙翻译一下啊!
各位大虾麻烦帮小弟翻译一下。
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
[解决办法]
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