# 第三方应用开放接口接入
# 说明
协议:HTTPS
请求方法:POST
数据格式:JSON
数据编码:UTF-8
# Header必传字段
Token: 业务接口调用凭据(获取方式),GetAccessToken,GetThirdAppBindCorpList接口除外
x-ql-corp-id:企业id(获取方式),GetAccessToken,GetThirdAppBindCorpList接口除外
# 请求示例
curl -X POST \
https://$basehost/gateway/qopen/xxx \
-H 'Content-Type: application/json;charset=UTF-8' \
-H 'Token: xxxxxx' \
-H 'x-ql-corp-id: xxxxxx' \
-d '{
"robot_id": "xxxxxx",
"group_id": "xxxxxx"
}'
请求返回数据示例:
请求返回值中固定返回 errcode
和 errmsg
字段
参数说明:
字段 | 类型 | 描述 |
---|---|---|
errcode | int | 状态码,0为正常,非0代表错误。全局错误码定义见:错误码。 |
errmsg | string | 错误信息,非0时会描述错误原因 |
hint | string | 请求日志ID,用于快速定位请求,如有问题反馈时带上该字段的值,有利于快速定位问题 |
成功
{
"data": {},
"errcode": 0,
"errmsg": "",
"hint": "yareMc0jYBY039NrYlUA"
}
失败
{
"data": {},
"errcode": 20402,
"errmsg": "",
"hint": "yareMc0jYBY039NrYlUA"
}
# 获取访问凭据
开发者通过此接口获取 access_token,调用接口获取资源时,需要使用 access_token 作为授权凭证。
生成和过期规则
- access_token 默认在生成7200秒(2小时)后过期,需要在过期前重新获取
- access_token 过期, 调用时会返回错误码 10001
- 当 app_secret 被重置时,当前 access_token 也会过期
请求方式:POST
请求地址:https://$basehost/gateway/qopen/GetAccessToken
body参数:
{
"app_key": "",
"app_secret": ""
}
字段 | 类型 | 必填/选填 | 说明 |
---|---|---|---|
app_key | string | 必填 | 用户唯一标识,可在设置中获得,app_key对应AppKey |
app_secret | string | 必填 | 企业API调用凭据,可在设置中获得,app_secret对应AppSecret |
获取路径:工作人员提供
返回值
{
"data": {
"data": {
"access_token": "",
"expires_in": 7200
}
},
"errcode": 0,
"errmsg": "",
"hint": ""
}
返回参数说明:
字段 | 类型 | 说明 |
---|---|---|
errcode | int | 状态码,0为正常,非0代表错误 |
errmsg | string | 错误信息 |
access_token | string | API调用凭据。调用其他业务 API 时需要在 header中 参数中带上此凭据 |
expires_in | int | 凭证有效时间,单位:秒 |
hint | string | 请求日志ID |
完整请求示例:
curl -X POST \
https://$basehost/gateway/qopen/GetAccessToken \
-H 'Content-Type: application/json; charset=UTF-8' \
-d ' {
"app_key": "",
"app_secret": ""
}'
# 获取第三方应用绑定的企业列表
第三方应用开发者通过此接口获取 绑定的企业列表,调用接口获取资源时,需要带上 x-ql-corp-id 头部。
请求方式:POST
请求地址:https://$basehost/gateway/qopen/GetThirdAppBindCorpList
body参数:
{
"app_key": "",
"app_secret": ""
}
字段 | 类型 | 必填/选填 | 说明 |
---|---|---|---|
app_key | string | 必填 | 第三方应用唯一标识,工作人员提供 |
app_secret | string | 必填 | 第三方应用API调用凭据,工作人员提供 |
返回值
{
"data": {
"corp_list": {
"corp_id": "",
"corp_name": ""
}
},
"errcode": 0,
"errmsg": "",
"hint": "",
}
返回参数说明:
字段 | 类型 | 说明 |
---|---|---|
errcode | int | 状态码,0为正常,非0代表错误 |
errmsg | string | 错误信息 |
corp_id | string | 企业id 第三方应用调用其他业务API 时需要在 header中 参数中带上此值 |
corp_name | string | 企业名称 |
hint | string | 请求日志ID |
完整请求示例:
curl -X POST \
https://$basehost/gateway/qopen/GetThirdAppBindCorpList \
-H 'Content-Type: application/json; charset=UTF-8' \
-d ' {
"app_key": "",
"app_secret": ""
}'
← 第三方应用回调事件接入 错误码与回调事件码 →