idhttp的用法

Posted 咏南中间件和开发框架

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了idhttp的用法相关的知识,希望对你有一定的参考价值。

1)POST

function PostMethod(http: TIDhttp; URL: string; Params: TStringList): string;
var
RespData: TStringStream;
begin
RespData := TStringStream.Create(‘‘);
try
try
if http = nil then
Exit;
Http.Post(URL, Params, RespData);
Result := RespData.DataString;
http.Request.Referer := URL;
except
Result := ‘‘;
Exit;
end;
finally
http.Disconnect;
FreeAndNil(RespData);
end;

2)GET

function GetMethod(http: TIDhttp; URL: string): string;
var
Resp: TStringStream;
begin
Resp := TStringStream.Create(‘‘);
try
try
Http.Get(URL, Resp);
Http.Request.Referer := URL;
Result := Resp.DataString;
except
Result := ‘‘;
Exit;
end;
finally
FreeAndNil(Resp);
end;
end;


end;

以上是关于idhttp的用法的主要内容,如果未能解决你的问题,请参考以下文章

IDHTTP的基本用法

idhttp的用法

delphi idhttp 实战用法(TIdhttpEx)

Delphi-idHttp-Post JSON用法 good

Delphi idhttp解决获取UTF-8网页中文乱码问题

idhttp访问出现onnection closed gracefully