通用识别(JSON / Base64)
' 说明:
' 1) 下面演示 VBScript 方式拼接 JSON 请求体。
' 2) 超时时间建议设置到 60 秒以上。
' 3) image 需要传纯 base64(不带 data:image/... 前缀)。
Dim apiUrl, username, password, typeid, imageBase64, jsonBody
apiUrl = "http://api.ttshitu.com/predict"
username = "你的账号"
password = "你的密码"
typeid = "3" ' 数英混合
imageBase64 = "请填入图片base64"
jsonBody = "{""username"":""" & username & """,""password"":""" & password & """,""typeid"":""" & typeid & """,""image"":""" & imageBase64 & """}"
Dim http
Set http = CreateObject("MSXML2.ServerXMLHTTP")
http.setTimeouts 60000, 60000, 60000, 60000
http.open "POST", apiUrl, False
http.setRequestHeader "Content-Type", "application/json;charset=UTF-8"
http.send jsonBody
WScript.Echo http.responseText
' success=true 时 data.result 为识别结果,data.id 可用于报错
报错脚本
Dim reportUrl, reportBody
reportUrl = "http://api.ttshitu.com/reporterror.json"
reportBody = "{""id"":""识别成功返回的id""}"
Dim reportHttp
Set reportHttp = CreateObject("MSXML2.ServerXMLHTTP")
reportHttp.open "POST", reportUrl, False
reportHttp.setRequestHeader "Content-Type", "application/json;charset=UTF-8"
reportHttp.send reportBody
WScript.Echo reportHttp.responseText
余额查询(GET)
Dim queryUrl
queryUrl = "http://api.ttshitu.com/queryAccountInfo.json?username=你的账号&password=你的密码"
Dim queryHttp
Set queryHttp = CreateObject("MSXML2.ServerXMLHTTP")
queryHttp.open "GET", queryUrl, False
queryHttp.send
WScript.Echo queryHttp.responseText