// 1. 获取前端传入的图片路径 【官方标准写法】
var imagePath = V8.Param.imagePath;
// 2. 获取 AccessToken
var tokenResult = V8.Http.Post({
Url: "https://aip.baidubce.com/oauth/2.0/token",
PostParam: {
grant_type: "client_credentials",
client_id: "jpVzjzhaZAPif4avIYlMj30L",
client_secret: "hH7jsc9BxBx7KcOYxWXHA0B4mg3C3XBq"
},
ParamType: "form",
Timeout: 10
});
var tokenData = JSON.parse(tokenResult);
var token = tokenData.access_token;
// 3. 调用百度OCR
var ocrResult = V8.Http.Post({
Url: "https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic",
PostParam: {
access_token: token,
url: imagePath, // 用上面拿到的变量
detect_direction: "false",
detect_language: "false",
paragraph: "false",
probability: "false"
},
ParamType: "form",
Timeout: 20
});
// 4. 返回结果给前端
return JSON.parse(ocrResult);
没有回复内容