天天看點

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;
           

傳回:

tms web core 調用webapi的方法