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的用法)