| 主機(jī)參考:VPS測評參考推薦/專注分享VPS服務(wù)器優(yōu)惠信息!若您是商家可以在本站進(jìn)行投稿,查看詳情!此外我們還提供軟文收錄、PayPal代付、廣告贊助等服務(wù),查看詳情! |
| 我們發(fā)布的部分優(yōu)惠活動(dòng)文章可能存在時(shí)效性,購買時(shí)建議在本站搜索商家名稱可查看相關(guān)文章充分了解該商家!若非中文頁面可使用Edge瀏覽器同步翻譯!PayPal代付/收錄合作 |
這次,我們將介紹微信共享功能的開發(fā)。 有哪些預(yù)防措施用于開發(fā)微信分享功能?以下是一個(gè)實(shí)際情況。讓我們看看。
在微信中嵌入的網(wǎng)頁在右上角具有默認(rèn)的共享功能。 如下圖所示,第一個(gè)圖像是自定義效果,第二張圖像是默認(rèn)效果。 人們是否想通過啟用自定義共享鏈接來點(diǎn)擊? 開發(fā)過程將在下面說明。
1。準(zhǔn)備配置JS接口安全域名。這需要使用微信的JSSDK。 必須將其設(shè)置為您的微信公共帳戶的背景。官方帳戶設(shè)置- ->功能設(shè)置- -> JS接口安全域名。 打開此頁面后,將提示您:必須先下載此文件并將其上傳到指定域名的根目錄。
此文件是一個(gè)字符串,用于基于名稱的驗(yàn)證。 您可以通過首先上傳成功保存此文件。 這使您可以使用JSSDK。
2。前端配置
要解釋的第一件事是共享功能是配置功能,當(dāng)綁定到按鈕單擊事件時(shí),沒有效果。 換句話說,只有單擊右上角的共享(我不知道如何實(shí)現(xiàn)文本內(nèi)容的共享)才能有效。 JS官方有四個(gè)步驟。 第一個(gè)是JSSDK:
腳本src = http://res.wx.qq.com/open/js/jweixin - set; }公共字符串noncestr {get;放; } public long timestamp {get;放; }公共字符串簽名{get;放; }公共字符串票{get;放; }公共stwist url {get;放; } public void makeign(){var string1builder = new StringBuilder(); string1builder.append(jsapi_ticket =)。append(ticke).append()。append(noncester =)。append()。append()。append()。 var string1 = string1builder.tostring(); signature = util.sha1(string1,encoding.default); }
然后配置:
wx.config({debug:true,//打開調(diào)試模式,所有稱為API的返回值都會(huì)被提醒到客戶端。要在PC側(cè)打開它們,參數(shù)信息將通過日志打印,將通過日志打印,只有PC端的標(biāo)識才能打印出來。 // signature signature signature: '@model.signature', // need, signature, signature, Jsapilist: [Checkjsapi, onmenretimeline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, Onmenusheline,Onmenusheline,Onmenusheline,Onmenusheline,Onmenusheline,Onmenusheline,Onmenusheline,Onmenusheline,Onmenusheline,Onmenusheline,Onmenusheline,Onmenusheline,Onmenusheline,Onmenusheline,Onmenusheline,Onmenushe,Onmenushe,OnmenusheeENUSHAREQQ,ONMENUSHAREQZONE] //您需要使用所需的JS接口列表,請參見附錄2}); wx.ready(function(){document.querySelector('#checkjsapi')。 //鏈接imgurl:'http://www.ward.com/images/s1.jpg alert(json.stringify(res));默認(rèn)鏈接dataurl:'',//如果類型是音樂或視頻,則必須提供默認(rèn)情況下的數(shù)據(jù)鏈接。 獲取Access_Token和JSAPI_Ticket生成正確的簽名。 https://api.weixin.qqc.com/cgi - bin/token?grant_type = crient_credential appid = {0} secret = {1} public tokenResult tokenresult getAccestoken() string.format(wxdeviceconfig.accestokenurlll,wxdevicecontedurl,wxdevicecontedurl wxdeviconfig.appsecret); jsapi_ticket
access_token是獲取jsapi_ticketRL:https://api.weixin.qq.com/cgi - bin/ticke/getTicket? access_token = access_token&type = jsapi,返回的json對象是:
{errcode:0,errmsg:ok ok,ticket:bxldikrxvbtpdpdhsm05e5e5e5suoxnkd8 - 41ZO3MHKOYN5OFKWITDGGNR2FWJ0M??9E8NYZWKVZVZVZVZVDVTAUUGWVSDSHFKA,型號:
公共類JsapiticketModel {public string {public string erncode {get;放; } public String errmsg {get;放; }公共字符串Expires_in {get;放; }}
如何完成門票完成:
public jsapiticketModel getjSapiticket(String accessToken){var url = string.format(wxpayConfig.jsapi_ticketurl,accessToken);返回sendhelp.send jsapiticketModel(accessToken,url,commonjSonsendType.get); }
門票也已到期7200秒,不能經(jīng)常要求,因此也必須在服務(wù)器端緩存。
私有void setCacheticket(字符串緩存)_cachemanager.set(toKenkey,Cache,7200); }
MemoryCacheManager:
查看代碼
您終于到達(dá)了這一點(diǎn),并在文檔中看到了一個(gè)讓您失望的場景。為什么未提供JSSDK?好吧,現(xiàn)在,不要抱怨。 官員們還解釋了簽署規(guī)則。 首先是https://github.com/night - king/weixinsdk:
public static String sha1(字符串orgstr,string concode = utf - 8){var sha1 = new sha1 = new sha1managed(); var sha1bytes = system.text.encoding.getencoding(encode).getBytes(orgstr); byte [] resulthash = sha1.computehash(sha1bytes);字符串sha1string = bitConverter.toString(resultash).tolower(); sha1string = sha1string.replace([-,返回sha1string;} //示例錯(cuò)誤
結(jié)果與正式驗(yàn)證不一致。SHA1CRYPTOSERVICEPROVIDER();putehash(bytes_in); sha1.dispose();字符串結(jié)果= bitconverter.tostring(bytes_out);結(jié)果=結(jié)果。replace([-,返回結(jié)果;}
,官方驗(yàn)證結(jié)果是可以的(忽略案例)。如果簽名的URL是參數(shù),則模型URL也必須使用參數(shù),并且## signature H5Share H5Share(
pobull rister errer errer risrer(
p> p> p> p> p> p> pobull) wxpayapi.generatenoncestr();P>
我認(rèn)為您在閱讀此情況后掌握了此方法。有關(guān)更多令人興奮的事情,請注意主機(jī)參考其他相關(guān)文章!
推薦閱讀:
使用Web Pack自動(dòng)更新和分析
使用H5 CACHESTEST
這幾篇文章你可能也喜歡:
- 開發(fā)微信支付退款職能
- 完整的微信官方帳戶開發(fā)教程1(微信官方帳戶開發(fā)教程視頻)
- 最適合Android開發(fā)的Linux發(fā)行版是什么?(linux android開發(fā))
- 哪個(gè)Linux系統(tǒng)最適合Android開發(fā)?
- linux在嵌入式系統(tǒng)開發(fā)領(lǐng)域的廣泛應(yīng)用(嵌入式Linux應(yīng)用場景)
本文由主機(jī)參考刊發(fā),轉(zhuǎn)載請注明:開發(fā)微信共享功能(實(shí)施微信共享功能) http://www.k2270.com/148452.html
主機(jī)參考
















評論前必須登錄!
注冊