想做一个读取邮箱的功能,这里用的是TOM的邮箱.代码如下procedure TForm1.LoginTomClick(Sender: TObject);
var
sPackage:Tstrings;
begin
IdHTTP1.ReadTimeout:=20000;
IdHTTP1.AllowCookies:=true;
if Assigned(IdHTTP1.CookieManager) then
IdHTTP1.CookieManager.CookieCollection.Clear;
IdHTTP1.Request.Referer:='';
IdHTTP1.HandleRedirects:=true;
IdHTTP1.HTTPOptions:=[hoKeepOrigProtocol]; //hoForceEncodeParams
IdHTTP1.ProtocolVersion:=pv1_1;
IdHTTP1.Request.Connection:='keep-alive';
IdHTTP1.Request.AcceptLanguage:='zh-cn,en-US;q=0.5';
IdHTTP1.Request.UserAgent:='Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; EmbeddedWB 14.52 from: http://www.bsalsa.com/ EmbeddedWB 14.52; .NET CLR 2.0.50727)'; sCookList := 'tom_test=djx867uzU!60!5!1270773219!1271473890!13!1271470436!http://mail.tom.com/!;'+
' vjuids=3dfe4b0e9.127dffc8129.0.5ba212ffc6e89; vjlast=1270773220.1271468863.11; '+
'TOM_USERNAME=likeyrain; ad_-.-AD-.-=m5UeE1yLG!16!4!1270775139!3!698752!8!0!0!null!!1271473891!!!; TUV=1271041674484841; [email protected]%20%20'; HostUrl:='http://mail.tom.com';
creferer:='http://www.tom.com'; sPackage:=TstringList.Create;
sPackage.Add('type = 0');
sPackage.Add('user = postmailtest');
sPackage.Add('in_username = [email protected]');
sPackage.Add('pass = 123456');
sPackage.Add('style = 21');
sPackage.Add('verifycookie = y'); IdHTTP1.Request.Referer:=creferer;
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
memo1.Lines.Text := IdHTTP1.Post(HostUrl, sPackage);
sPackage.Free;
end;但是这样反回的,并不是登录成功的内容,不知道上面是哪里错了,或者还有什么事情没做?
var
sPackage:Tstrings;
begin
IdHTTP1.ReadTimeout:=20000;
IdHTTP1.AllowCookies:=true;
if Assigned(IdHTTP1.CookieManager) then
IdHTTP1.CookieManager.CookieCollection.Clear;
IdHTTP1.Request.Referer:='';
IdHTTP1.HandleRedirects:=true;
IdHTTP1.HTTPOptions:=[hoKeepOrigProtocol]; //hoForceEncodeParams
IdHTTP1.ProtocolVersion:=pv1_1;
IdHTTP1.Request.Connection:='keep-alive';
IdHTTP1.Request.AcceptLanguage:='zh-cn,en-US;q=0.5';
IdHTTP1.Request.UserAgent:='Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; EmbeddedWB 14.52 from: http://www.bsalsa.com/ EmbeddedWB 14.52; .NET CLR 2.0.50727)'; sCookList := 'tom_test=djx867uzU!60!5!1270773219!1271473890!13!1271470436!http://mail.tom.com/!;'+
' vjuids=3dfe4b0e9.127dffc8129.0.5ba212ffc6e89; vjlast=1270773220.1271468863.11; '+
'TOM_USERNAME=likeyrain; ad_-.-AD-.-=m5UeE1yLG!16!4!1270775139!3!698752!8!0!0!null!!1271473891!!!; TUV=1271041674484841; [email protected]%20%20'; HostUrl:='http://mail.tom.com';
creferer:='http://www.tom.com'; sPackage:=TstringList.Create;
sPackage.Add('type = 0');
sPackage.Add('user = postmailtest');
sPackage.Add('in_username = [email protected]');
sPackage.Add('pass = 123456');
sPackage.Add('style = 21');
sPackage.Add('verifycookie = y'); IdHTTP1.Request.Referer:=creferer;
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
memo1.Lines.Text := IdHTTP1.Post(HostUrl, sPackage);
sPackage.Free;
end;但是这样反回的,并不是登录成功的内容,不知道上面是哪里错了,或者还有什么事情没做?
HostUrl:string;
creferer:string;在单元和私有变量里定义了
'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; EmbeddedWB 14.52 from: http://www.bsalsa.com/ EmbeddedWB 14.52; .NET CLR 2.0.50727)';推举用WSockExpert 截取一下,看看和你上面的有差别没有。感觉你截取的少了一些参数
HostUrl:='http://login.mail.tom.com';
却报“http/1.1 405 method not allowed”这样的错误,这是发包的内容错了还是网站不容许外部发包啊?