欧美free性护士vide0shd,老熟女,一区二区三区,久久久久夜夜夜精品国产,久久久久久综合网天天,欧美成人护士h版

目錄

柚子快報(bào)邀請(qǐng)碼778899分享:微信小程序用戶(hù)手機(jī)號(hào)授權(quán)獲取

柚子快報(bào)邀請(qǐng)碼778899分享:微信小程序用戶(hù)手機(jī)號(hào)授權(quán)獲取

http://yzkb.51969.com/

要想成功獲取微信小程序手機(jī)號(hào),應(yīng)該先明確:

一、明確微信小程序規(guī)則

1.現(xiàn)微信規(guī)定不能在onLoad,onShow這類(lèi)頁(yè)面觸發(fā)函數(shù)中直接獲取

2.只能通過(guò)用戶(hù)行為觸發(fā),比如點(diǎn)擊某個(gè)按鈕

二、獲取手機(jī)號(hào)的流程

1.公眾平臺(tái)獲取appId與secret

2.結(jié)合手機(jī)號(hào)按鈕及其事件綁定,獲取?code

3.調(diào)用接口獲取?access_token

4.根據(jù) code 與?access_token 獲取手機(jī)號(hào)

根據(jù)以上步驟, 我們直接從第二步開(kāi)始:

1.此處的code是需要先寫(xiě)一個(gè)官方提供的特殊的按鈕:

然后在js中寫(xiě)上改按鈕綁定的函數(shù)getPhoneNumber,根據(jù)以下寫(xiě)法獲取code:

2.調(diào)用

`https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${appId}&secret=${secret}`

查詢(xún)參數(shù):grant_type=client_credential&appid=yourAppid&secret=yourSecret

注意:這里的grant_type=client_credential固定寫(xiě)法,appid和secret是微信公眾平臺(tái)查的。

示例:

3.調(diào)用

`https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=${access_token}`

查詢(xún)參數(shù):access_token 直接使用上一步獲取到的即可。

請(qǐng)求體數(shù)據(jù):code 在按鈕事件綁定的函數(shù)getPhoneNubmer中e.detail.code獲取得到。

示例:

完整代碼演示:

//綁定手機(jī)

getPhoneNumber: function (e) {

console.log(e);

const code = e.detail.code

wx.request({

url: `https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${appId}&secret=${secret}`,

method: 'GET',

success:res=>{

if(res.statusCode!==200) return

const access_token = res.data.access_token

wx.request({

url: `https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=${access_token}`,

method: 'POST',

data: {

code

},

success:data=>{

if(data.statusCode!==200) return

const { phoneNumber } = data.data.phone_info // 這里就是獲取到的手機(jī)號(hào)

}

})

}

})

},

通過(guò)以上步驟,就可以實(shí)現(xiàn)點(diǎn)擊按鈕彈出手機(jī)號(hào)獲取授權(quán),點(diǎn)擊確認(rèn)即可獲取到用戶(hù)的手機(jī)號(hào)了~

柚子快報(bào)邀請(qǐng)碼778899分享:微信小程序用戶(hù)手機(jī)號(hào)授權(quán)獲取

http://yzkb.51969.com/

參考閱讀

評(píng)論可見(jiàn),查看隱藏內(nèi)容

本文內(nèi)容根據(jù)網(wǎng)絡(luò)資料整理,出于傳遞更多信息之目的,不代表金鑰匙跨境贊同其觀點(diǎn)和立場(chǎng)。

轉(zhuǎn)載請(qǐng)注明,如有侵權(quán),聯(lián)系刪除。

本文鏈接:http://gantiao.com.cn/post/19336787.html

發(fā)布評(píng)論

您暫未設(shè)置收款碼

請(qǐng)?jiān)谥黝}配置——文章設(shè)置里上傳

掃描二維碼手機(jī)訪問(wèn)

文章目錄