idHTTP 向网站发送json格式数据

idHTTP 向网站发送json格式数据

var
rbody:tstringstream;
begin
rbody:=tstringstream.Create('{"name":"lina"}') ;
IdHTTP1.Request.Accept := 'text/javascript';
IdHTTP1.Request.ContentType := 'application/json';
IdHTTP1.Request.ContentEncoding := 'utf-8';
 
memo1.Text:=idhttp1.Post('http://127.0.0.1/idhttpjson.php', RBody);
end;

发送普通格式

var
  Param:TStringList;
begin
  Param:=TStringList.Create;
  Param.Add('name=lina');
  memo1.Text:=IdHTTP1.Post('Http://127.0.0.1/idhttpjson.php', Param);
end;

https://bbs.csdn.net/topics/390551578

posted @ 2019-01-19 10:29  覆雨翻云  阅读(808)  评论(0编辑  收藏  举报