RestAPI
# PinToo RestAPI
PinToo中包含了RestAPI客户端的相关功能,可通过RestAPI获取相关的请求信息。
我们以PinToo快速上手中的示例为例,以Myrtille Login API为使用的API参照,在其中再添加一个TfxMemo
组件,在其中Lines
中输入登录使用的Body信息。
在fxButton1OnClick
事件中添加以下脚本信息。其中的处请修改为自己设定的Myrtille地址。其中使用到的关键脚本为fxfun.NetHttpPost。
Procedure fxButton1OnClick(Sender: TObject);
var
QUrl: String;
QSource: String;
QContentType: String;
Begin
QUrl := 'http://{{server}}:8008/MyrtilleAdmin/ConnectionService/GetConnectionId';
QSource := fxMemo1.Lines.Text;
QContentType := 'application/json';
ShowMessage(fxfun.UrlDecode(fxfun.NetHttpPost(QUrl,QSource,QContentType)));
End;
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
将此模板同步至Android设备,再次运行此脚本,如果设置正确的话,会在对话框中显示预期收到的信息。
关于其他RestAPI相关的函数可参考fxfun.NetHttpClientPost以及fxfun.NetHttpGet。