tms web core 調用webapi的方法

 

webhttprequest組件屬性設置。 

header:

Cache-Control=no-cache, no-store, must-revalidate
Content-Type=application/x-www-form-urlencoded

Postdata:

date=20200509&sign=94487aaeabc723bc6fe6dc95d958708f&token=&param={"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;

返回:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章