# 获取手机号
接口应在服务器端调用,详细说明参见服务端 API>)。
本接口支持云调用>)。需开发者工具版本 >=
1.02.1904090
(最新稳定版下载),wx-server-sdk
>=0.4.0
# 接口说明
# 接口英文名
getPhoneNumber
# 功能描述
该接口用于将 code 换取用户手机号。 说明,每个 code 只能使用一次,code 的有效期为 5min。
# 调用方式
# HTTPS 调用
POST https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=ACCESS_TOKEN
# 云调用
出入参和 HTTPS 调用相同,调用方式可查看云调用说明文档
接口方法为: openapi.phonenumber.getPhoneNumber
# 第三方调用
调用方式以及出入参和 HTTPS 相同,仅是调用的 token 不同
该接口所属的权限集 id 为:18
服务商获得其中之一权限集授权后,可通过使用authorizer_access_token代商家进行调用
# 请求参数 - Query
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
access_token / cloudbase_access_token | string | 是 | 接口调用凭证>) |
# 请求参数 - Body
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
code | string | 是 | 手机号获取凭证 | |
openid | string | 否 |
# 返回参数
属性 | 类型 | 说明 | |||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
errcode | number | 错误码 | |||||||||||||||||||||||||||||||||||||
errmsg | string | 错误信息 | |||||||||||||||||||||||||||||||||||||
phone_info | object | 用户手机号信息 | |||||||||||||||||||||||||||||||||||||
|
# 调用示例
示例说明: HTTPS 请求示例
# 请求数据示例
{
"code": "e31968a7f94cc5ee25fafc2aef2773f0bb8c3937b22520eb8ee345274d00c144"
}
# 返回数据示例
{
"errcode": 0,
"errmsg": "ok",
"phone_info": {
"phoneNumber": "xxxxxx",
"purePhoneNumber": "xxxxxx",
"countryCode": 86,
"watermark": {
"timestamp": 1637744274,
"appid": "xxxx"
}
}
}
# 错误码
错误码 | 错误描述 | 解决方案 |
---|---|---|
-1 | system error | 系统繁忙,此时请开发者稍候再试 |
40029 | code 无效 | js_code 无效 |
45011 | api minute-quota reach limit mustslower retry next minute | API 调用太频繁,请稍候再试 |
40013 | invalid appid | 请求 appid 身份与获取 code 的小程序 appid 不匹配 |