webhttprequest組件屬性設置。
header:
Cache-Control=no-cache, no-store, must-revalidate
Content-Type=application/x-www-form-urlencoded
Postdata:
date=20200509&sign=94487aaeabc723bc6fe6dc95d958708f&token=¶m={"phone":"13900010123","password":"123"}
url:
http://web.api.com/appapi/index/login
command:httpPOST;
使用:
uese
WEBLib.JSON;
procedure TForm4.WebHttpRequest1Response(Sender: TObject; AResponse: string);
var
js: TJSON;
ja: TJSONArray;
jo: TJSONObject;
i: integer;
begin
WebMemo1.Lines.Add(AResponse);
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('flag'));
WebListBox1.Items.Add(jo.GetJSONValue('data'));
WebListBox1.Items.Add(jo.GetJSONValue('user'));
WebListBox1.Items.Add(jo.GetJSONValue('company'));
end;
finally
js.Free;
end;
end;
WebHttpRequest1.Execute;
返回: