webqq2.0协议研究(2)-登录

   get方式登录

   地址:http://ptlogin2.qq.com/login?u={0}&p={1}&verifycode={2}&webqq_type=1&remember_uin=1&aid=1002101&u1=http%3A%2F%2Fweb2.qq.com%2Floginproxy.html%3Fstrong%3Dtrue&h=1&ptredirect=0&ptlang=2052&from_ui=1&pttype=1&dumy=&fp=loginerroralert HTTP/1.1

 

   0为 qq号码  1为加密后的密码 2为验证码(如果不需要验证码这里就要填写返回的!开头的4位验证码)

 

   密码的加密算法为:Utils.getMd5Hash2(Utils.getMd5Hash(password).ToUpper() + VerifyCode.ToUpper()).ToUpper();

  getMd5Hash为三次次md5加密    getMd5Hash2为一次md5加密

 

  服务器返回ptuiCB('0','0','http://web2.qq.com/loginproxy.html?strong=true','0','登录成功!');
   第一个0是服务器返回的状态码,0表示登录成功,一共有20多个状态,分别如下:

webqq2.0协议研究(2)-登录

 

  此次提交后,如果返回成功,则携带cookie可以直接访问QQ空间,soso,等其他tx的产品

 

  返回成功后还不能真正登录webQQ2.0,需要再次提交以下参数

  地址:http://web2-b.qq.com/channel/login

   参数:r=%7B%22status%22%3A%22%22%2C%22ptwebqq%22%3A%22{0}%22%2C%22passwd_sig%22%3A%22%22%2C%22clientid%22%3A%22{1}%22%7D

   {0}为cookie里的ptwebqq   {1}为clientid

    post提交

 

   服务器返回:{"retcode":0,"result":{"uin":845609272,"mode":"master","index":1056,"port":39085,"status":"online","vfwebqq":"4da040662484002027cecfee8afe92b077550b0ee56b5ef4630245c80dcda9f18cba5b915a0ad16a","psessionid":"8368036764001D636F6E6E7365727665725F77656271714031302E3133332E322E313434000035F30000000C026E040038F966326D0000000A407A6372575761536C43"}}

    retcode":0," 表示成功,返回里关键的是vfwebqq参数,这个在以后的操作会经常用到

     以上过程不完整,有待更新

 

     相关代码:

 

 

 

初始化
   
     
public bool initWebqq()
{
string url = " http://web2-b.qq.com/channel/login " ;
// string url = " http://im2.qq.com/conn_s ";
string postData = string .Format( " r=%7B%22status%22%3A%22%22%2C%22ptwebqq%22%3A%22{0}%22%2C%22passwd_sig%22%3A%22%22%2C%22clientid%22%3A%22{1}%22%7D "
, user.ptwebqq,user.ClientId);

string result = HttpHelper.GetHtml(url, postData, true , user.Cookie);

if (result.Contains( " \ " retcode\ " :0 " ))
{
user.Key
= Utils.getStringByRegex(result, " (vfwebqq\ " :\ " )(?<key>.+?)(\ " }}) " , " key " , 0);
return true ;
}
else
{
user.Key
= "" ;
return false ;
}
}

 

 

   

   

登录
   
     
/// <summary>
/// web2qq登陆方法
/// 登陆需要初始化UserEntity的用户名,密码,验证码。
/// </summary>
public void loginWebQQ()
{
string url = String.Format( " http://ptlogin2.qq.com/login?u={0}&p={1}&verifycode={2}&webqq_type=1&remember_uin=1&aid=1002101&u1=http%3A%2F%2Fweb2.qq.com%2Floginproxy.html%3Fstrong%3Dtrue&h=1&ptredirect=0&ptlang=2052&from_ui=1&pttype=1&dumy=&fp=loginerroralert HTTP/1.1 "
, user.Username, user.Password, user.VerifyCode);
string result = HttpHelper.GetHtml(url, user.Cookie);

string state = "" ;
if (result != "" )
{
state
= result.Substring( 8 , 1 );
}
if (state == " 0 " )
{
user.Status
= UserStatus.Logined;
// string results = HttpHelper.GetHtml(" http://ptlogin2.qq.com/group2?skey= "+user.Skey+"&uin=415516174&gid=8033525&type=102&uri=share", user.Cookie);
}
else if (state == " 4 " )
{
user.Status
= UserStatus.VerifyCodewang;
}
else
{
user.Status
= UserStatus.loginwang;
}

}

 

 

你可能感兴趣的:(Web)