# 客服输入状态
接口应在服务器端调用,不可在前端(小程序、网页、APP等)直接调用,具体可参考接口调用指南
接口英文名:typing
本接口用于设置客服输入状态。
# 1. 调用方式
# HTTPS 调用
POST https://api.weixin.qq.com/cgi-bin/message/custom/typing?access_token=ACCESS_TOKEN
# 云调用
- 本接口不支持云调用
# 第三方调用
本接口支持第三方平台代商家调用。
该接口所属的权限集 id 为:1、6、19、100-101
服务商获得其中之一权限集授权后,可通过使用 authorizer_access_token 代商家进行调用,具体可查看 第三方调用 说明文档。
# 2. 请求参数
# 查询参数 Query String parameters
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
access_token | string | 是 | 接口调用凭证,可使用 access_token、authorizer_access_token |
# 请求体 Request Payload
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
touser | string | 是 | 用户的 OpenID |
command | string | 是 | 命令。Typing表示对用户下发"正在输入"状态 ;CancelTyping表示取消对用户的"正在输入"状态 |
# 3. 返回参数
# 返回体 Response Payload
参数名 | 类型 | 说明 |
---|---|---|
errcode | number | 错误码 |
errmsg | string | 错误信息 |
# 4. 注意事项
# 注意
- 公众号和服务号调用时,请求地址为:
POST https://api.weixin.qq.com/cgi-bin/message/custom/typing?access_token=ACCESS_TOKEN
- 小程序和小游戏调用时,请求地址为:
POST https://api.weixin.qq.com/cgi-bin/message/custom/business/typing?access_token=ACCESS_TOKEN
# 5. 代码示例
请求示例
{
"touser":"OPENID",
"command":"Typing"
}
返回示例
{
"errcode": 0,
"errmsg": "ok"
}
# 6. 错误码
以下是本接口的错误码列表,其他错误码可参考 通用错误码
错误码 | 错误描述 | 解决方案 |
---|---|---|
-1 | system error | 系统繁忙,此时请开发者稍候再试 |
40001 | invalid credential access_token isinvalid or not latest | 获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口 |
40200 | invalid account type | 账号类型不符合要求 |
45072 | invalid command | command字段取值不对 |
45080 | need sending message to user orrecving message from user in the last 30 seconds before typing | 下发输入状态,需要之前30秒内跟用户有过消息交互 |
45081 | you are already typing | 已经在输入状态,不可重复下发 |
# 7. 适用范围
本接口在不同账号类型下的可调用情况:
小程序 | 公众号 | 服务号 | 小游戏 |
---|---|---|---|
✔ | 仅认证 | 仅认证 | ✔ |
- ✔:该账号可调用此接口
- 仅认证:表示仅允许企业主体已认证账号调用,未认证或不支持认证的账号无法调用
- 其他未明确声明的账号类型,如无特殊说明,均不可调用此接口;