云开发小程序如何获取用户的手机号

小程序 文章 2021-03-17 17:01 441 0 全屏看文

AI助手支持GPT4.0

云开发小程序如何获取用户的手机号How to obtain the user's mobile phone number for the cloud development applet

云开发小程序如何获取用户的手机号


云开发小程序如何获取用户的手机号

~


官方文档

1、https://developers.weixin.qq.com/miniprogram/dev/component/button.html

2、https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html

首先我说下做这个的场景,近期在迭代培训刷题小程序,该小程序支持线上和线下报名,对于线上报名的用户平台会电话引导购买其他付费服务,这个时候对于手机号的正确收集是非常有必要的

那么能不能通过文本框让用户自己输入呢,这样做其实也不是不可以的,但是目前常规的做法就是利用微信的


微信开放能力直接获取微信实名认证绑定的手机号,由于目前基本绝大部分手机都实名认证了,所以这个方式就非常自然

~

其实在之前的开发中,也做过手机号码的获取工作,但是当时是在社区随便找了一个可行方案,没有严格按照官方指定的方案来,这次就顺着官方提供的思路实现了下

真好看

具体代码就是增加以下二块

1、


2、

对的,你看到了,创建的云函数就是默认的初始化代码,但是这样就work的,不妨可以试试


How to get the user's mobile phone number ~ official document 1 https://developers.weixin.qq.com/miniprogram/dev/component/button.html 2、 https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html First of all, I'll talk about the scenario of doing this. Recently, I've been iteratively training the topic brushing applet, which supports online and offline registration. The online registration user platform will call to guide the purchase of other paid services. At this time, it's very necessary to collect the correct mobile phone number So can we let users input by themselves through the text box? In fact, it's not impossible to do so. But at present, the conventional way is to use wechat's wechat open ability to directly obtain the mobile phone number bound with wechat's real name authentication. Because most mobile phones have real name authentication, this way is very natural~ In fact, in the previous development, I also did the work of obtaining mobile phone numbers, but at that time, I found a feasible solution in the community. I didn't strictly follow the plan specified by the official. This time, I followed the idea provided by the official. You laugh very well. The specific code is to add the following two pieces of 1, 2 Yes, as you can see, the created cloud function is the default initialization code, but it's work like this. You can try it

回答:

红小豆:

利用微信的开放能力获取手机号,是需要企业资质的,所以对于个人小程序是不支持的,这一点需要格外注意。

红小豆:

res.result.event.wuRunData.data.phoneNumber

红小豆:

官方提供了以下二种方案,本文采用了第二种方式来实现

服务端获取开放数据

小程序可以通过各种前端接口获取微信提供的开放数据。考虑到开发者服务端也需要获取这些开放数据,微信提供了两种获取方式:


方式一:开发者后台校验与解密开放数据

方式二:云调用直接获取开放数据(云开发)


-EOF-

AI助手支持GPT4.0


国内超级便宜服务器

摸鱼人热门新闻聚合

钻级赞助商 我要加入

开发者在线工具

第三方支付技术请加QQ群

相关文章
暂未查询到营业执照注册号?
scroll-view 的 skip-hidden-item-layout属性无效?
请问小程序流量主广告收益还有救吗?收益从8月份跌去一半之后,这次元旦过后又迎来大跌?
onShareAppMessage 的 imageUrl 可以是base64吗?
突然 大面积公众号报 该公众号提供的服务出现故障,请稍后再试 ?
随便看看
教育科技公司申请微信支付被拒绝? 3940
微信公众号免300认证教程 5051
小程序已经上线,作为管理员无法在小程序数据助手查看数据? 4369
小程序广告组件通过审核,但是小程序内没有显示广告? 4342
企业微信通讯录账号被管理员误/恶意删除,怎么办? 8362
问题? 7479
如何快速搭建抽奖助手小程序(无需代码知识) 5157
许涛 大哥在吗, 要解冻小程序的时候提示信息主体不一致, 能帮忙看下吗? 6213
小程序搜一搜全称搜索不显示 麻烦解决一下!谢谢 5727
我的小程序广告收款主体是个体工商户,每个月邮寄两次发票很是麻烦,我年底的时候打包邮寄一次可以么? 5296