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;

posted @ 2016-12-20 12:43  delphi中间件  阅读(2062)  评论(0编辑  收藏  举报