在后台调用getuserphonenumber接口一直报错,是不能在后台用吗?

小程序 文章 2022-03-07 14:20 688 0 全屏看文

AI助手支持GPT4.0

在后台调用getuserphonenumber接口一直报错,是不能在后台用吗?Calling the getuserphonenumber interface in the background keeps reporting an error. Can it be used in the background?

在后台调用getuserphonenumber接口一直报错,是不能在后台用吗?

小程序需要获取手机号,通过界面按钮获取code值后,提交给后台获取手机号:

1、通过接口:https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=""&secret=""获取到access_token值后调用接口:

2、https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token='+access_token+"&code="+phoneCode,调用后提示:

data format error hint: [Wgdbr7Ore-oEm.7] rid: 62259c4a-7c28684e-6eb764dc

The applet needs to obtain the mobile phone number. After obtaining the code value through the interface button, submit it to the background to obtain the mobile phone number: 1. Through the interface: https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid= "" & Secret = "" get access "_ Token value after calling interface: 2, https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token= '+access_ Token + "& code =" + phonecode, prompt after calling: data format error hint: [wgdbr7ore OEM. 7] rid: 62259c4a-7c28684e-6eb764dc

回答:

拾忆:

需要通过用户触发button按钮返回的code才可以。

再见,电脑崽:

微信的请求都是POST的而且数据是json格式,文档稍微有点误导:

curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"code": "e31968a7f94cc5ee25fafc2aef2773f0bb8c3937b22520eb8ee345274d00c144"}' https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=ACCESS_TOKEN
VBit:

code不要写在url里面

~^_^~:去掉了提示错误码40029,invalid code hint: [DGdb9_I2e-ve1C6a] rid: 6225a161-6f4c1862-196a5fd3
~^_^~:可以了,谢谢,code值用过一次了

-EOF-

AI助手支持GPT4.0


国内超级便宜服务器

摸鱼人热门新闻聚合

钻级赞助商 我要加入

开发者在线工具

第三方支付技术请加QQ群

相关文章
VantWeapp field组件通过button-slot插入的按钮为啥不能更改大小?
小程序获取手机号新方式怎么拿不到code啊?
使用this.setData后,数据更新成功,但是页面数据不更新?这是为什么?
建议文档写清楚点
电商收付通,合单支付分润是针对单笔子订单分润还是整笔订单分润?
随便看看
微信公众号免300认证教程 4965
小程序已经上线,作为管理员无法在小程序数据助手查看数据? 4084
小程序广告组件通过审核,但是小程序内没有显示广告? 4263
企业微信通讯录账号被管理员误/恶意删除,怎么办? 8042
问题? 7267
如何快速搭建抽奖助手小程序(无需代码知识) 5050
许涛 大哥在吗, 要解冻小程序的时候提示信息主体不一致, 能帮忙看下吗? 6007
小程序搜一搜全称搜索不显示 麻烦解决一下!谢谢 5521
我的小程序广告收款主体是个体工商户,每个月邮寄两次发票很是麻烦,我年底的时候打包邮寄一次可以么? 5216
如何解决渲染层网络错误Failed to load media? 16566