phonenumber.getPhoneNumber的调用究竟需传什么参数?

小程序 文章 2022-02-15 09:20 1798 0 全屏看文

AI助手支持GPT4.0

phonenumber.getPhoneNumber的调用究竟需传什么参数?What parameters need to be passed in the call of phonenumber.getPhoneNumber?

phonenumber.getPhoneNumber的调用究竟需传什么参数?

phonenumber.getPhoneNumber

//我的调用方法如下wx.request({    url:'https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token='+this.accessToken.access_token,  method:'POST',  header: {'content-type''application/json'},   data:{   // appid:this.appid,  // secret:this.secret,  code:this.loginCode,  // encryptedData:this.phoneNumber.encryptedData,   // iv: this.phoneNumber.iv  },   success:function(res){     console.log(res.data)   }})//返回的结果errcode40029errmsg"invalid code hint: [RJGACOLoRa-AGMPWa] rid: 620a4ce4-20963e07-281d13a8"

phonenumber.getPhoneNumber //我的调用方法如下wx.request({ url:'https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token='+this.accessToken.access_token,  method:'POST',  header: {'content-type': 'application/json'},  data:{  // appid:this.appid,  // secret:this.secret,  code:this.loginCode,  // encryptedData:this.phoneNumber.encryptedData,  // iv: this.phoneNumber.iv  },  success:function(res){  console.log(res.data)  }})//返回的结果errcode: 40029errmsg: "invalid code hint: [RJGACOLoRa-AGMPWa] rid: 620a4ce4-20963e07-281d13a8"

回答:

brave:

微信服务端接口不能直接在前端调用:

无code自行排查:

① 确认当前基础库版本是否为 2.21.2 及以上。

② 目前开发者工具稳定版未兼容此表现(近期应该会同步)。

③ 正常情况下,基础库 2.21.2 对应的是客户端版本号为 8.0.16,如果你的版本低于 8.0.16 并且是通过开发者工具向客户端推送的 2.21.2 基础库,大几率不会返回 code 参数,请手动更新微信版本。

目前请先用 开发版 或者 真机 进行调试。

Mr.Zhao:

工具更新版本啊

拾忆:

1.api接口需要服务端请求,不能在小程序内直接请求

2.code需要通过按钮open-type类型为getPhoneNumberbindtap事件触发才能获取到code

不想当:我是通过官方文档中的按钮获取的手机号,如下

-EOF-

AI助手支持GPT4.0