怎么用IDHTTP登陆QQ空间?const
     Const_PostLoginInfo = 'u=%s&p=%s&verifycode=%s';
     Const_PostLoginStr = '&aid=15000102&u1=http%3A%2F%2Fxiaoyou.qq.com%2Findex.php%3Fmod%3D'+
                          'login&fp=&h=1&ptredirect=1&ptlang=0&from_ui=1&dumy=';function LoginQQ(aIdHTTP: TIdHTTP; aUserNameStr, aPasswordStr, aVerifyStr: string; var aWebStr: string): Boolean;
var
   PostData, RespData: TStringStream;
   tmpStr: string;
begin
    PostData:= TStringStream.Create( Format(Const_PostLoginInfo, [aUserNameStr,
                                                            Preprocess(aPasswordStr, aVerifyStr),
                                                            aVerifyStr])
                                                           + Const_PostLoginStr); RespData:= TStringStream.Create('');
     Result:= False;     
     
     aWebStr:= '';
     try
        aIdHTTP.ReadTimeout:= 15000;
        aIdHTTP.Request.Accept:='*/*';
        aIdHTTP.Request.ContentType:= 'application/x-www-form-urlencoded';
        aIdHTTP.Request.Host:= 'ptlogin2.qq.com';
        aIdHTTP.Request.Referer:= 'http://ui.ptlogin2.qq.com/cgi-bin/login?appid=15000102';
        aIdHTTP.Request.UserAgent:= 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)';
        aIdHTTP.Request.AcceptEncoding:= 'gzip, deflate';
        aIdHTTP.Request.URL:= 'http://ptlogin2.qq.com/login';
        //aIdHTTP.Request.SetHeaders;
        aIdHTTP.Request.RawHeaders.Values['Cookie'] := 'Cookie:'+QQ_Cookie;
        aIdHTTP.Post('http://ptlogin2.qq.com/login', PostData, RespData);
        tmpStr:= Utf8ToAnsi(RespData.DataString);
        if pos('如果未能自动跳转,请<a href="http://xiaoyou.qq.com/index.php?mod=login" target="_top">点击</a>完成跳转。</div>', tmpStr)>0 then
        begin
           Result:= True;
           tmpStr:= SubString(aIdHTTP.Response.RawHeaders.Text, 'Set-Cookie: pt2gguin=', ';');
           Cookie_pt2gguin:= tmpStr;
           tmpStr:= SubString(aIdHTTP.Response.RawHeaders.Text, 'Set-Cookie: uin=', ';');
           Cookie_uin:= tmpStr;
           tmpStr:= SubString(aIdHTTP.Response.RawHeaders.Text, 'Set-Cookie: skey=', ';');
           Cookie_skey:= tmpStr;
           tmpStr:= SubString(aIdHTTP.Response.RawHeaders.Text, 'Set-Cookie: ptcz=', ';');
           Cookie_ptcz:= tmpStr;
           QQ_Cookie:= QQ_Cookie + ' pt2gguin=' + Cookie_pt2gguin + '; uin=' + Cookie_uin + '; skey=' +
                       Cookie_skey + '; ptcz=' + Cookie_ptcz + ';';
        end
        else if pos('超时', tmpStr)>0 then 
            aWebStr:= '连接超时或者页面出错!'
        else if pos('验证码', tmpStr)>0 then 
            aWebStr:= '验证码错误!'
        else if pos('密码', tmpStr)>0 then 
            aWebStr:= '密码错误!';
        if Trim(aWebStr)='' then
           aWebStr:= '帐号受限或者其它原因不能登录!';
     except
        Result:= False;   
        aWebStr:= '连接超时或者页面出错!';
     end;
     
     PostData.Free;
     RespData.Free; 
end;
这里这段根本就登陆不了,每次登陆就会提示"帐号受限或者其它原因不能登录"

解决方案 »

  1.   

    兄弟,你好!我也在弄哈哈……看看:
      //这一句里面的%s重复出现了三次 你能看得出什么破绽吗?嘿嘿,其实你再细看,u(ser)=();p(assword)=();verifycode=(); ^_^ 看到了吧!! QQ号码-密码-验证码(密码还必须处理下,是变态的MD5算法);
       Const_PostLoginInfo = 'u=%s&p=%s&verifycode=%s';
      //这句可以看出是登录QQ校友的,并不是QQ空间;
       Const_PostLoginStr = '&aid=15000102&u1=http%3A%2F%2Fxiaoyou.qq.com%2Findex.php%3Fmod%3D'+
      'login&fp=&h=1&ptredirect=1&ptlang=0&from_ui=1&dumy=';
    (小弟偶刚刚进来鬼混,不劳你多多关照哦!)