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.youkuaiyun.com/topics/390551578
本文介绍使用IDHTTP组件向服务器发送JSON格式及普通格式数据的方法。通过示例代码展示如何设置请求头,包括Content-Type和Accept,并使用TStringStream和TStringList创建请求体,最终通过Post方法发送数据。
8538

被折叠的 条评论
为什么被折叠?



