Jump to content

simple way to POST to URL


Kachar ganyalong

Recommended Posts


function PostString(s, url:string):string;
var
aResponse: TStringStream;
aParams:TStringList;
mHTTP:TidHTTP;
LHandler: TIdSSLIOHandlerSocketOpenSSL;
begin
mHTTP := TIdHTTP.Create(nil);
mHTTP.Request.BasicAuthentication:=false;
aParams := TStringList.Create;
try
LHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
aParams.add('Body='+s);
aResponse := TStringStream.Create;
try
mHTTP.IOHandler:=LHandler;
mHTTP.Post(url, aParams, aResponse);
finally
Result:=aResponse.DataString;
LHandler.Free;
end;
finally
aParams.Free;
aResponse.Free;
mHTTP.Free;
end;
end;

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...