USEGEAR

导航

调用 restful的api的方法

var
//  myurl : string;
  tmpstr : String;// string;
  RespData :TStringStream;
  sendData : TStringList;
  jo : ISuperObject;
begin
  try
    RespData := TStringStream.Create('data');
    sendData :=  TStringList.Create;
    sendData.Text :=System.UTF8Encode(AnsiToUtf8('{"UserName":"'+UserName+'","UserPW":"'+UserPW+'"}'));
    tmpstr :=(idhtp.Post('http://196.168.1.78:8090/api/RLogin',sendData));
    delete(tmpstr,1,3);
    mmo1.Lines.Add(tmpstr);
    try
      jo := SO(tmpstr);
      pToken:= jo['Data.Token'].AsString;
mmo1.Lines.Add('pToken='+pToken);
      Result := True;
    except
      pToken := '';
      Result := False;
    end;
  finally
     FreeAndNil(RespData);
     FreeAndNil(sendData);
  end;
end;

 

posted on 2021-03-26 17:52  USEGEAR  阅读(287)  评论(0编辑  收藏  举报