用python或者使用工具Postman来,获取百度云文字识别中的access_token

百度云文字识别:

1,注册账户:https://login.bce.baidu.com

2,创建应用后点击应用就可以看到AK(API Key)和SK(Secret Key)

一、用python脚本获取access_token:

二、用工具Postman获取access_token:

百度文字识别调用方式文档地址:https://cloud.baidu.com/doc/OCR/s/Ck3h7y2ia

1,Postman是一个比较给力的Http请求模拟工具,可以快速进行接口调用。

2,输入HTTP请求的几个部分:

1,请求的method:选择POST

2,填写URL

3,Params:

  • grant_type: 必须参数,固定为client_credentials;

  • client_id: 必须参数,应用的API Key;

  • client_secret: 必须参数,应用的Secret Key

获取ccess_token后,postman中进行接口调用,需要输入的其他2个参数:

1,填写请求头(Headers)

  •  Key栏输入:Content-Type
  • Value栏输入:application/x-www-form-urlencoded

2,输入请求参数(body)

    先选择“x-www-form-urlencoded”,

  • access_token = xxx 把之前获取到的token字符串填到这里来
  • image = xxx 把图片转成base64字符串填到这里,转码工具:https://www.css-js.com/tools/base64.html
  • url = xxx 也可以不用传图片而是传一个图片的链接。
  • language_type = CHN_ENG 识别语言类型。默认中英。

猜你喜欢

转载自www.cnblogs.com/zhangyy177/p/12168175.html