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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...