范例一:开发者账号
URL := 'https://opi.tinysoft.com.cn/Service/OPS/Subscription/time';
username := "yourname"; //需换成天软账号
password := "yourpass"; //需换成对应密码
header := "Connection: keep-alive\r\nContent-Type: application/json\r\nJSON-Encode: gbk";
ses := createhttpsession();
sethttpmode(ses, 1); //设置chunked模式(分段模式)
for i := 0 to 9999 do
begin
ret := InternetRequest(ses, URL, "", header, '{"anyname":"example"}', username, password, 0, res, resp, 500000);// {"anyname":"example"}用于传递参数,若无,可以设置为{}
echo "code:", resp, "->", res, "\r\n";
if ret then echo "time is:", datetimetostr(importjsonstring(res)["time"]), "\r\n";
end;
结果:
范例二:特殊租户(调用功能列表为*,等同于开发者)
URL := 'https://opi.tinysoft.com.cn/Service/OPS/Subscription/time';
sessionkey := "{xxx-xxx}"; //用户需替换成自己的session-key
header := "Connection: keep-alive\r\nContent-Type: application/json\r\nJSON-Encode: gbk\r\nAuthorization: Bearer "+sessionkey;
ses := createhttpsession();
sethttpmode(ses, 1); //设置chunked模式(分段模式)
for i := 0 to 9999 do
begin
ret := InternetRequest(ses, URL, "", header, '{"anyname":"example"}', "", "", 0, res, resp, 500000);// {"anyname":"example"}用于传递参数,若无,可以设置为{}
echo "code:", resp, "->", res, "\r\n";
if ret then echo "time is:", datetimetostr(importjsonstring(res)["time"]), "\r\n";
end;
结果:
