本文整理自网络,侵删。
TWebHttpRequest使用
TWebHttpRequest通过HTTP GET方法,向中间件REST API申请数据。
procedure TForm1.WebButton1Click(Sender: TObject);begin WebHttpRequest1.URL := 'https://jsonplaceholder.typicode.com/albums'; WebHttpRequest1.Execute;end; procedure TForm1.WebHttpRequest1Response(Sender: TObject; AResponse: string);var js: TJSON; ja: TJSONArray; jo: TJSONObject; i: integer;begin js := TJSON.Create; try ja := TJSONArray(js.Parse(AResponse)); ShowMessage('Retrieved items:' +inttostr(ja.Count)); for i := 0 to ja.Count - 1 do begin jo := TJSONObject(ja.Items[i]); WebListBox1.Items.Add(jo.GetJSONValue('title')); end; finally js.Free; end;end;
https://www.cnblogs.com/hnxxcxg/p/10395022.html
相关阅读 >>
Delphi firedac 获取 insert 记录的自增 id
更多相关阅读请进入《Delphi》频道 >>