時(shí)間:2022-08-06 19:06:01 | 來源:網(wǎng)站運(yùn)營(yíng)
時(shí)間:2022-08-06 19:06:01 來源:網(wǎng)站運(yùn)營(yíng)
一、JS-SDK說明文檔/*1.獲取code的url(訪問微信官方服務(wù)器獲取code) --- 用戶操作之后才能有code,如點(diǎn)擊頁面的授權(quán)按鈕。*/`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${APPID}&redirect_uri=${url}&response_type=code&scope=snsapi_userinfo&state=STATE&connect_redirect=1#wechat_redirect`/*2.獲取網(wǎng)頁授權(quán)access_token的url(訪問微信官方服務(wù)器獲取)*/`https://api.weixin.qq.com/sns/oauth2/access_token?appid=${APPID}&secret=${SECRET}&code=${CODE}&grant_type=authorization_code`
2)其他微信接口,需要通過基礎(chǔ)支持中的“獲取access_token”接口來獲取到的普通access_token調(diào)用。獲取此access_token需要給微信服務(wù)器接口(https://api.weixin.qq.com/cgi-bin/token)兩個(gè)參數(shù)(appid,appsercet)/*獲取js-sdk的jsapi_ticket(臨時(shí)票據(jù)),獲取普通access_token的url(訪問微信官方服務(wù)器獲取臨時(shí)票據(jù))*/`https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${APPID}&secret=${SECRET}`
三、應(yīng)用 const url = encodeURIComponent(location.href.split('#')[0]) axios.get(`https://xxxx/api/usersticket?url=${url}`).then((res) => { const {APPID, timestamp, noncestr, signature, url} = res.data wx.config({ debug: false, // 測(cè)試時(shí)改為true。 appId: APPID, timestamp, nonceStr: noncestr, signature, jsApiList: [ 'onMenuShareAppMessage', 'onMenuShareTimeline' ] }) wx.ready(() => { wx.onMenuShareAppMessage({ title: '自定義', desc: '自定義', link: url, imgUrl: '自定義', success: () => { console.log('分享成功了!') }, cancel: () => { console.log('分享失敗了!') } }) wx.onMenuShareTimeline({ title: '自定義', link: url, imgUrl: '自定義', success: () => { console.log('分享成功了!') }, cancel: () => { console.log('分享失敗了!') } }) }) wx.error(res => { console.log(res) }) }).catch(err => { console.log(err) })
關(guān)鍵詞:公眾
客戶&案例
營(yíng)銷資訊
關(guān)于我們
客戶&案例
營(yíng)銷資訊
關(guān)于我們
微信公眾號(hào)
版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。