身份证识别 error_code: 216201
酒后一炮思前仇 发布于2020-07 浏览:3035 回复:4
0
收藏

egg.js 调用身份证识别接口错误返回:

}
  log_id: 564888582608514370,
  error_code: 216201,
  error_msg: 'image format error'
}

 

客户端相关代码:

 

服务端相关代码:

// 身份证识别
async getIdcardInfo(imgBase) {
  const ctx = this.ctx;
  const token = await this.getAccessToken();
  let res = "";

  try {
    const result = await ctx.curl(
      `https://aip.baidubce.com/rest/2.0/ocr/v1/idcard?access_token=${token}`,
      {
        headers: {
          "content-type": "application/x-www-form-urlencoded",
        },
        method: "POST",
        dataType: "json",
        data: {
          image: urlencode(imgBase),
          id_card_side: "front",
        },
      }
    );

    if (result.res.status === 200) {
      console.log(result.res.data);
      res = result.res.data;
      return res;
    }
  } catch (err) {
    console.log("http请求出错:", err);
    ctx.logger.error(new Error(`获取Access Token:${err}`));
    return res;
  }
}

 

token返回正常, 图片base64正常

收藏
点赞
0
个赞
共4条回复 最后由用户已被禁言回复于2022-04
#10用户已被禁言回复于2022-04

http://accaspace.com/search?key=%E5%AE%89%E5%BE%BD%E6%A1%90%E5%9F%8E%E7%9C%9F%E4%BA%BA%E6%96%97%E7%89%9B%E5%AE%98%E7%BD%91TL262%C2%B7C%EF%BC%AFM%E9%93%9C%E9%99%B5%E5%88%86%E5%85%AC%E5%8F%B8%EF%BD%99%EF%BC%B4%EF%BC%81 https://b2b.baidu.com/s?q=%E6%96%B0%E7%99%BE%E8%83%9C%E5%A8%B1%E4%B9%90%E4%B8%8B%E8%BD%BD%E7%94%B5%E8%AF%9DB2024%C2%B7CN%E6%B7%AE%E5%AE%89%E7%94%B5%E5%8F%B0%EF%BC%AD&from=search http://www.huanqiu.cc/search/index.html?keyword=%E6%96%B0%E7%99%BE%E8%83%9C%E6%B8%B8%E6%88%8F%E7%BD%91%E5%9D%80%E5%85%AC%E5%8F%B8%E6%98%AF%E5%A4%9A%E5%B0%91%E7%99%BB%E5%BD%95%E7%BD%91%E5%9D%80%E5%BC%80%E6%88%B7B2024.cN%E9%93%9C%E9%99%B5%E5%8C%BB%E4%BF%9D%EF%BC%B8 https://list.jd.com/search?keyword=%E8%80%81%E8%A1%97%E7%9A%87%E5%AE%B6%E5%88%A9%E5%8D%8E%E5%A8%B1%E4%B9%90%E7%94%B5%E8%AF%9D%E5%A4%9A%E5%B0%91%E5%AE%98%E7%BD%91TL262%C2%B7%EF%BC%A3%EF%BC%AF%EF%BC%AD%E6%80%80%E5%8C%96%E7%83%AD%E6%90%9C https://www.linkedin.com/help/linkedin/answers/%E9%87%91%E5%A5%A5%E9%BE%99%E6%8F%90%E7%8E%B0%E5%BF%AB%E4%B8%8D%E5%BF%AB%E3%80%90%E5%AE%98%E7%BD%91%E2%86%92B2024%C2%B7CN%E3%80%91%E5%B4%87%E5%B7%A6%E5%8D%AB%E8%A7%86%EF%BC%A1

0
#4Randcase回复于2020-08

写了 格式错误啊

0
#3用户已被禁言回复于2020-07

imgBase 是什么(确保是base64)?还有图片自身的格式是否符合接口要求。支持jpg/jpeg/png/bmp格式

1
#2深圳九曲范深回复于2020-07

可以q498250371   或者工单咨询

 

0
TOP
切换版块