function httpPost(URL:string;Input:string;var Back:string):Boolean;
var
path:string;
str:string;
postStream: TStringStream;
AEnctryRespose: string;
i:Integer;
list:THashedStringList;
begin
try
Result:= False;
list:= THashedStringList.Create;
path:= GetCurrentDir;
Gv_Log.Addlog('url:'+ url);
Gv_Log.Addlog('input:'+ input);
IdHTTP1 := TIdHTTP.Create(nil);
// IdSSLIOHandlerSocketOpenSSL1 := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
// IdHTTP1.IOHandler := IdSSLIOHandlerSocketOpenSSL1;
IdHTTP1.HandleRedirects := True;
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
list.CommaText:= input;
for i:=0 to list.Count -1 do
begin
str:=str+ list[i]+'&';
end;
str:= Copy(str,1,Length(str)-1);
postStream:=TStringStream.Create(ansitoUTF8(str));
try
AEnctryRespose := IdHTTP1.Post(url, postStream);
Back:= Utf8ToAnsi(AEnctryRespose);
gv_log.Addlog('工商返回:'+ Back);
Result:= True;
except
on e:Exception do
begin
gv_log.Addlog('post异常'+ e.Message);
end;
end;
finally
IdHTTP1.Free;
list.Free;
postStream.Free;
end;
end;```
delphi post key value
最新推荐文章于 2024-04-07 06:36:38 发布