我試圖登錄到網站,但這個網站總是德爾福HTTP POST方法 - 曲奇問題
迴應「你似乎並不接受Cookies Cookies是需要的,以登錄。」
爲什麼我的程序不允許cookies?
function HF_Login(): boolean;
var
HTTP : TIDHTTP;
Cookie : TidCookieManager;
Data, Page : TStringList;
begin
HTTP := TIDHTTP.Create(NIL);
Cookie := TidCookieManager.Create(NIL);
HTTP.Request.UserAgent := 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1';
HTTP.Request.Accept := 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
HTTP.Request.AcceptLanguage := 'en-us;q=0.7,en;q=0.3';
HTTP.Request.AcceptCharSet := 'windows-1251,utf-8;q=0.7,*;q=0.7';
HTTP.Request.Pragma := 'no-cache';
HTTP.Request.CacheControl := 'no-cache';
HTTP.Request.RawHeaders.Add('X-Requested-With: XMLHttpRequest');
HTTP.AllowCookies := True;
HTTP.HandleRedirects := True;
HTTP.ProtocolVersion := pv1_1;
HTTP.Request.Connection := 'Keep-Alive';
HTTP.CookieManager := Cookie;
Data := TStringList.Create;
Page := TStringList.Create;
// returnto=%2F&user=[user]&pass=[pass]
Data.Add('returnto=%2F&user=csz0021&pass=Yese0071');
page.Text := HTTP.Post('http://hotfile.com/login.php', Data);
//form1.RichEdit1.Text := HTTP.Post('http://hotfile.com/login.php', Data);
If Pos('Bad username/password combination.', Page.Text) <> 0 Then Result := False
else Result := True;
Page.Free;
Data.Free;
end;
這是一個免費的帳戶來測試網站。
csz0021
Yese0071
感謝
這個C#代碼工作完美也許這可以幫助你在delphi代碼中找到我的問題http://stackoverflow.com/questions/2151576/c-http-post-method-cookies-issue – MeRo 2011-04-20 14:19:09