How to make an HTTPS POST request in Delphi?

前端 未结 3 705
臣服心动
臣服心动 2020-12-31 04:14

What is the easiest way to do an HTTPS POST request in Delphi? I\'m not having problems with making HTTP POST requests, but how can I do it using SSL? I\'ve googled around a

相关标签:
3条回答
  • 2020-12-31 04:32

    Another alternative to Indy is Synapse.

    This class library offers full control of the post, but also offers a simple one liner post method as well:

    function HttpPostURL(const URL, URLData: string; const Data: TStream): Boolean;
    
    0 讨论(0)
  • 2020-12-31 04:43

    You didn't specified your Delphi version or indy version, but I had some problems before with the bundled Indy with Delphi 2009 and HTTPS, and when I got the latest source from indy svn, the problem solved.

    0 讨论(0)
  • 2020-12-31 04:45

    http://chee-yang.blogspot.com/2008/03/using-indy-https-client-to-consume.html

    var S: TStringList;
       M: TStream;
    begin
     S := TStringList.Create;
     M := TMemoryStream.Create;
     try
       S.Values['Email'] := 'your google account';
       S.Values['Passwd'] := 'your password';
       S.Values['source'] := 'estream-sqloffice-1.1.1.1';
       S.Values['service'] := 'cl';
    
       IdHTTP1.IOHandler := IdSSLIOHandlerSocketOpenSSL1;
       IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
       IdHTTP1.Post('https://www.google.com/accounts/ClientLogin', S, M);
       Memo1.Lines.Add(Format('Response Code: %d', [IdHTTP1.ResponseCode]));
       Memo1.Lines.Add(Format('Response Text: %s', [IdHTTP1.ResponseText]));
    
       M.Position := 0;
       S.LoadFromStream(M);
       Memo1.Lines.AddStrings(S);
     finally
       S.Free;
       M.Free;
     end;
    

    end;

    0 讨论(0)
提交回复
热议问题