webQQ3.0协议登录
想用webQQ3.0的协议登录进去,
1.检查是否需要验证码;
地址(GET):http://ptlogin2.qq.com/check?uin=********(QQ号码)&appid=1003903(固定)&r=0.2664082343145449(随机18位 简单的说 0.后面+随机16位数)
返回数据:
返回数据(需要验证码):
ptui_checkVC('1','8a6143167c8ca486696cf01c3ea088d658b913d64b11289b'(验证码数据,这个数据在第一次获取验证码时作为参数来获取。));
返回数据(不需要验证码):
“ptui_checkVC('0','!OMD');”
判断1=需要验证码,0=不需要
判断8a6143167c8ca486696cf01c3ea088d658b913d64b11289b或 !OMD 我们叫他为key
Key 长度大于4,需要验证码。
问题如下:<form id="login" runat="server" method="get" action="http://ptlogin2.qq.com/check">
<asp:TextBox runat="server" ID="uin" Width=100></asp:TextBox><br />
<asp:TextBox runat="server" ID="appid" Width=100></asp:TextBox><br />
<asp:Button ID="r" runat="server" Text="0.8178352857537984"
onclick="bt_login_Click" />
</form>
点击按钮后网页显示:ptui_checkVC('0','!XUC');
想问怎样才能得到服务器返回的字符。
[解决办法]
private String getUrl(String url)
{
try
{
HttpWebRequest myRequest = (HttpWebRequest)HttpWebRequest.Create(url);
myRequest.Method = "GET";
if (refer != null)
{
myRequest.Referer = refer;
}
CookieContainer cc = new CookieContainer();
myRequest.CookieContainer = cc;
myRequest.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";
myRequest.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.8) Firefox/3.6.8";
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
if(myResponse.Headers.Get("Set-Cookie") != null)
{
cookie = myResponse.Headers.Get("Set-Cookie");
}
Stream newStream = myResponse.GetResponseStream();
StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
string res = reader.ReadToEnd();
return res;
}
catch (Exception e)
{
MessageBox.Show(e.GetType().ToString() + e.Message);
return null;
}
}
用这个函数获取 返回的res就是你要的那个数据 参数url就是带参数的网址http://ptlogin2.qq.com/check?uin=********(QQ号码)&appid=1003903(固定)&r=0.2664082343145449