万象优图的人脸核身接口一直返回5?

  • 回答 (1)
  • 关注 (0)
  • 查看 (90)

使用的是nodejs,代码如下所示:

```js

var request = require('request');

var CryptoJS = require("crypto-js");

// var Base64 = require('js-base64').Base64;

var appid = '1253143079';

var bucket = 'rlhs';

var secretID = 'AKIDQlvtgKI8NRK2YsiwfHhx0rW1PpHkFZrx';

var secretKey = '8oLgpmXIvPmy2EIAqvsdEB2lKhvypW7b';

var currentTime = Math.floor(new Date().getTime() / 1000)

var expiredTime = currentTime + 2592000;

var rand = Math.floor(Math.random() * 100);

var userid = '0';

var auth = `a=${appid}&b=${bucket}&k=${secretID}&e=${expiredTime}&t=${currentTime}&r=${rand}&u=${userid}`;

console.log(auth)

auth = CryptoJS.HmacSHA1(auth, secretKey)

console.log(auth)

// auth = Base64.encode(auth.toString())

auth = CryptoJS.enc.Base64.stringify(auth)

console.log(auth)

request({

url: 'http://service.image.myqcloud.com/face/idcardcompare',

method: 'POST',

headers: {

'content-type': 'application/json',

Authorization: auth

},

json: true,

body: {

appid,

idcard_number: '李四',

idcard_name: '339005199111115115',

url: 'http://www.ninix.cn/common/imgs/logo.png',

},

callback(err, httpResponse, body){

console.log(body)

}

})

```

用户1095498用户1095498提问于
Ne_biubiubiu这就是世界结束的方式回答于

签名串错误,检查下你的签名是否正确

扫码关注云+社区

领取腾讯云代金券