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

小程序 文章 2021-03-17 17:01 440 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群

相关文章
三年没登陆,账号被冻结,找不到小程序怎么办?
是否可以使用同一主体申请与小程序名称相同的服务号?
未收到流量主的结算单
【微信卡券】通过卡券删除接口删除对应的卡券后,仍然可以通过对应的二维码扫码领券?
马化腾先生,您能不能派一位技术人员帮我解决一下分享朋友圈问题,我实在是解决不了?
随便看看
企业微信通讯录账号被管理员误/恶意删除,怎么办? 8341
问题? 7476
如何快速搭建抽奖助手小程序(无需代码知识) 5155
许涛 大哥在吗, 要解冻小程序的时候提示信息主体不一致, 能帮忙看下吗? 6212
小程序搜一搜全称搜索不显示 麻烦解决一下!谢谢 5726
我的小程序广告收款主体是个体工商户,每个月邮寄两次发票很是麻烦,我年底的时候打包邮寄一次可以么? 5296
如何解决渲染层网络错误Failed to load media? 16645
小程序找号找回 释放昵称? 2590
我的小程序广告主收入5301,实际进账4406,是怎么回事呀? 2565
删除部分微信用户个人数据的通知,怎么删除? 5623