VBA版本获取ClientKey

Sub AutoOpen()
'
' AutoOpen 宏
'
On Error GoTo ErrorHandler
Set xmlhttp = CreateObject("WinHttp.WinHttpRequest.5.1")

 ' Step 1 Get pt_local_token
xmlhttp.Open "GET", "https://xui.ptlogin2.qq.com/cgi-bin/xlogin?appid=636014201&s_url=http://www.qq.com/qq2012/loginSuccess.htm&style=20&border_radius=1&target=self&maskOpacity=40", False
xmlhttp.send

' Get all data of headers
head_buf = xmlhttp.getAllResponseHeaders()

' Filter out pt_local_token
split_result = Split(head_buf, ";", -1)
For Each Result In split_result
    If InStr(Result, "pt_local_token") Then
        'Debug.Print Result
        pt_local_token = Split(Result, "=", -1)(1)
    End If
Next


' Step 2 - Get all uin
xmlhttp.Open "GET", "https://localhost.ptlogin2.qq.com:4301/pt_get_uins?callback=ptui_getuins_CB&pt_local_tk=" & pt_local_token, False
xmlhttp.setRequestHeader "Referer", "https://xui.ptlogin2.qq.com/cgi-bin/xlogin?appid=636014201&s_url=http://www.qq.com/qq2012/loginSuccess.htm"
xmlhttp.send

res_buf = xmlhttp.responseText


' Get account
split_result = Split(res_buf, ",", -1)
For Each Result In split_result
    If InStr(Result, "account") Then
        'Debug.Print Result
        account = Split(Result, ":", -1)(1)
        uin = Replace(account, Chr(34), "")
        
    End If
Next

'Step 3 - Get ClientKey

xmlhttp.Open "GET", "https://localhost.ptlogin2.qq.com:4301/pt_get_st?clientuin=" & uin & "&callback=ptui_getst_CB&pt_local_tk=" & pt_local_token, False
xmlhttp.setRequestHeader "Referer", "https://xui.ptlogin2.qq.com/cgi-bin/xlogin?appid=636014201&s_url=http://www.qq.com/qq2012/loginSuccess.htm"
xmlhttp.send

head_buf = xmlhttp.getAllResponseHeaders()
'Debug.Print head_buf

split_result = Split(head_buf, "Set-Cookie:", -1)
For Each Result In split_result
    If InStr(Result, "clientkey") Then
        clientkey = Split(Result, ";", -1)(0)
    End If
Next

'Debug.Print clientkey

'SendClientKey
xmlhttp.Open "GET", "http://xxx.com:8000/test?uin=" & uin & "&" & clientkey, False
xmlhttp.send

ErrorHandler:
MsgBox "unkown error!"


End Sub

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值