問題があります tIdhttp を使用して目的のサイトに問題なく接続できますが、問題は他のボタンから接続できないことです。
関数の外でこれらの変数を宣言しました..これは役立つと思いましたが、そうではありませんでした
var
Form1: TForm1;
HTTP : TIDHTTP;
Cookie : TidCookieManager;
implementation
{$R *.dfm}
そしてこれは関数で
HTTP := TIDHTTP.Create(NIL);
Cookie := TidCookieManager.Create(nil);
HTTP.Request.UserAgent := 'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; Acoo Browser 1.98.744; .NET CLR 3.5.30729)';
HTTP.Request.Accept := 'text/html, */*';
HTTP.Request.CacheControl := 'no-cache';
HTTP.AllowCookies := True;
HTTP.HandleRedirects := True;
HTTP.ProtocolVersion := pv1_1;
HTTP.CookieManager := Cookie;
HTTP.RedirectMaximum := 15;
Data := TStringList.Create;
Page := TStringList.Create;
Data.Add('LoginForm[username]=xxxLoginForm[password]=xxx&LoginForm[rememberMe]=0');
Page.Text := HTTP.Post('http://somesite.com/login.html',Data);
If Pos('>Logout', Page.Text) = 0 Then Result := False
else Result := True;
Page.Free;
Data.Free;
// HTTP.Free;
end;
ボタン2
HTTP.Get('http://somesite.cc/info/523364d0/'); // this does not work it show that im not connected ..but the function already connected to the site.
ボタン1で、関数を使用して正常に接続(サイトにログイン)できます。次に、HTTP.getを使用してボタン2をクリックしてファイルを取得しますが、ログインしていないことが示されるので、プログラムを接続したままにすることができます。再度ログインせずに(他のボタンで)get pageを呼び出します。
私の悪い英語でごめんなさい。