怎么用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;
这里这段根本就登陆不了,每次登陆就会提示"帐号受限或者其它原因不能登录"
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;
这里这段根本就登陆不了,每次登陆就会提示"帐号受限或者其它原因不能登录"
解决方案 »
- 捕捉socket错误,高手请进啊
- 急急急~!!!如何使用DBGrid处理多条记录???
- 2000,XP中显示器和系统匹配的问题?
- 麻烦看一下这段代码哪里有问题,在线等
- *****麻烦大家看看这个错误怎么解决!![Fatal Error] XMLUtils.pas(24): Read error on '.\output\Unicode.dcu'
- SetLength()函数超出内存,怎么办
- 特难:我在三层中上传ClientDataSet.data属性都能成功。为何下载就不成功了。
- 如何提取一个网页中所有的链接(包括链接文字)
- 我很失望这里没有DELPHI高手!!!!!!!!!!1
- webservice
- ADO 查 MYSQL 100万记录的表,查5条记录都慢得不行,怎么办呢
- 请问Stream.DataString出来的string是一个上面编码,这个编码能改吗?
//这一句里面的%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=';
(小弟偶刚刚进来鬼混,不劳你多多关照哦!)