How to make an HTTPS POST request in Delphi?

前端 未结 3 706
臣服心动
臣服心动 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: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;

提交回复
热议问题