本文整理自网络,侵删。
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 systemparametersinfo 用法
Delphi 关于 beep、messagebeep 和 windows.beep
Delphi 中 findwindow 和 findwindowex 的语法和用法
Delphi 2009 新增单元 character isletter、isupper、islower、isdigit、isnumber
更多相关阅读请进入《Delphi》频道 >>