一.申请百度AI开放平台自然语言处理apikey
二.通过apikey与api secret获取access_token
获取access_token
1.百度比较贴心,会有获取access_token的demo给到你,我这里用的是python
代码如下:
import requests
#client_id 为官网获取的AK
#client_secret 为官网获取的SK
host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=【官网获取的AK】&client_secret=【官网获取的SK】'
response = requests.get(host)
if response:
print(response.json())
输出结果如下:
三.查看api文档把调用api封装成函数
1.下面是请求示例