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:= 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/msword, */*';
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(WebStr)='' then
WebStr:= '帐号受限或者其它原因不能登录。';
except
Result:= False;
aWebStr:= '连接超时或者页面出错!';
end;
PostData.Free;
RespData.Free;
end;怎么调用谢了!!!!
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:= 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/msword, */*';
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(WebStr)='' then
WebStr:= '帐号受限或者其它原因不能登录。';
except
Result:= False;
aWebStr:= '连接超时或者页面出错!';
end;
PostData.Free;
RespData.Free;
end;怎么调用谢了!!!!
aIdHTTP: TIdHTTP; //TIdHttp控件对象
aUserNameStr, //用户名字符串
aPasswordStr, //密码字符串
aVerifyStr: string; //校验码字符串
var aWebStr: string //一个字符串变量,用于存储函数执行完毕,函数执行结果所显示的字符串
这个地址根本不存在呀?
怎么登录?