Delphi-idHttp-JSON用法
(2014-05-07 20:52:51)从国外网站抄来的代码
Delphi source:
http := TIdHttp.Create(nil);
http.HandleRedirects := True;//允许头转向
http.ReadTimeout := 5000;//请求超时设置
http.Request.ContentType := 'application/json';//设置内容类型为json
jsonToSend := TStringStream.Create('{"name":"Peter Pan"}');//创建一个包含JSON数据的变量
jsonToSend.Position := 0;//将流位置置为0
Memo1.Lines.Text := http.Post('http://www.website.com/test.php', jsonToSend);//用MEMO控件接收POST后的数据返回
jsonToSend.free; http.free;//用完记得释放