??
WeChat JS-SDK? WeChat ?? ????? ? ???? ?? ???? WeChat ??? ? ?? ?????.
WeChat JS-SDK? ???? ? ???? WeChat? ???? ?? ??, ?? ??, ?? ??, ?? ? ??? ???? ??? ????? ???? ??? WeChat? ?? ??? ? ????. ??, ??, ?? ?. ??? ?? WeChat? ??? ??? WeChat ????? ? ?? ? ??? ?????.
? ??? ? ???? ???? WeChat JS-SDK ?? ?? ? ?? ????? ???? ?? ???????.
JSSDK ?? ??
1??: ??? ?? ???
?? WeChat ?? ???? ????? "?? ?? ??"? "?? ??"? ??? "JS ????? ?? ??? ??"? ?????.
??: ??? ? "??? ??"?? ?? ????? ??? ??? ? ????.
2??: JS ?? ??
JS ?????? ???? ?? ???? ?? JS ??? ?????. (https ??) : http://www.miracleart.cn/
??: AMD/CMD ?? ?? ?? ??? ??? ?? ??
3??: config ?????? ?? ?? ?? ?? ??
JS-SDK? ???? ?? ?? ???? ?? ?? ??? ???? ???. ??? ??? ???? ????. (??? URL? ? ?? ???? ?? SPA ? ?? ?????. URL? ??? ??? URL? ??? ? ????. ?? Android WeChat ?????? pushState? ??? H5 ??? ???? ???? pushState? ???? ? ? ???? ???? ? ??? ?????. ????? 6.2??).
wx.config({ ????debug:?true,?//?開(kāi)啟調(diào)試模式,調(diào)用的所有api的返回值會(huì)在客戶端alert出來(lái),若要查看傳入的參數(shù),可以在pc端打開(kāi),參數(shù)信息會(huì)通過(guò)log打出,僅在pc端時(shí)才會(huì)打印。 ????appId:?'',?//?必填,公眾號(hào)的唯一標(biāo)識(shí) ????timestamp:?,?//?必填,生成簽名的時(shí)間戳 ????nonceStr:?'',?//?必填,生成簽名的隨機(jī)串 ????signature:?'',//?必填,簽名,見(jiàn)附錄1 ????jsApiList:?[]?//?必填,需要使用的JS接口列表,所有JS接口列表見(jiàn)附錄2 });
4??: ??? ?????? ?? ???? ?? ??
wx.ready(function(){ ????//?config信息驗(yàn)證后會(huì)執(zhí)行ready方法,所有接口調(diào)用都必須在config接口獲得結(jié)果之后,config是一個(gè)客戶端的異步操作,所以如果需要在頁(yè)面加載時(shí)就調(diào)用相關(guān)接口,則須把相關(guān)接口放在ready函數(shù)中調(diào)用來(lái)確保正確執(zhí)行。對(duì)于用戶觸發(fā)時(shí)才調(diào)用的接口,則可以直接調(diào)用,不需要放在ready函數(shù)中。 });
5??: ?? ?????? ?? ??? ?? ??
wx.error(function(res){ ????//?config信息驗(yàn)證失敗會(huì)執(zhí)行error函數(shù),如簽名過(guò)期導(dǎo)致驗(yàn)證失敗,具體錯(cuò)誤信息可以打開(kāi)config的debug模式查看,也可以在返回的res參數(shù)中查看,對(duì)于SPA可以在這里更新簽名。 });
????? ?? ??
?? ?????? wx ??? ?????(?? jWeixin ??? ???? ??? ? ????. ????? ? ????? ???? ???? ?? ???? ??? ??? ?? ?? ????? ????.
-
success: ????? ?? ?? ? ???? ?? ?????. fail: ????? ??? ???? ? ???? ?? ?????.
??: ??, ??? ???? ????? ??? ???? ???? ?? ?????.
cancel: ???? ??? ??? ?? ?? ??? ???? ??? ???? ???? ?????.
trigger: ??? ??? ???? ? ???? ??????. ? ???? ??? ?? ?????? ?????.
- ??: ?? ????? ?? ??? ?? ????? ????? ajax ??? ??? ???? ? ??? ??? ???? ????. ajax ?? ???? ??????. ?? ???? ?????.
???? ??? ??: "xxx: cancel" , ??? xxx? ??? ?????? ?????.
??? ??? ?? ?? ?? ?? ?? ??????.
/// <summary> /// 微信參數(shù)準(zhǔn)備 /// </summary> private void WxSdkPramas(bool isShare) { var jsSdk = new JSSDKHelper(); //獲取時(shí)間戳 var timestamp = JSSDKHelper.GetTimestamp(); //獲取隨機(jī)碼 var nonceStr = JSSDKHelper.GetNoncestr(); var appId = WeiXinAppId; var appSecret = WeiXinAppSecret; //獲取票證 var jsTicket = JsApiTicketContainer.TryGetTicket(appId, appSecret); //獲取簽名 var signature = jsSdk.GetSignature(jsTicket, nonceStr, timestamp, Request.Url.AbsoluteUri); ViewData["AppId"] = appId; ViewData["Timestamp"] = timestamp; ViewData["NonceStr"] = nonceStr; ViewData["Signature"] = signature; }
??? js ?? ?????:
<head> <meta name="viewport" content="width=device-width" /> <title>公眾號(hào)JSSDK演示</title> <script src="~/Scripts/jquery-1.7.1.min.js"></script> <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script> <script> wx.config({ debug: false, // 開(kāi)啟調(diào)試模式,調(diào)用的所有api的返回值會(huì)在客戶端alert出來(lái),若要查看傳入的參數(shù),可以在pc端打開(kāi),參數(shù)信息會(huì)通過(guò)log打出,僅在pc端時(shí)才會(huì)打印。 appId: '@ViewData["AppId"]', // 必填,公眾號(hào)的唯一標(biāo)識(shí) timestamp: '@ViewData["Timestamp"]', // 必填,生成簽名的時(shí)間戳 nonceStr: '@ViewData["NonceStr"]', // 必填,生成簽名的隨機(jī)串 signature: '@ViewData["Signature"]',// 必填,簽名 jsApiList: [ "checkJsApi", 'onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'hideMenuItems', 'showMenuItems', 'hideAllNonBaseMenuItem', 'showAllNonBaseMenuItem', 'translateVoice', 'startRecord', 'stopRecord', 'onRecordEnd', 'playVoice', 'pauseVoice', 'stopVoice', 'uploadVoice', 'downloadVoice', 'chooseImage', 'previewImage', 'uploadImage', 'downloadImage', 'getNetworkType', 'openLocation', 'getLocation', 'hideOptionMenu', 'showOptionMenu', 'closeWindow', 'scanQRCode', 'chooseWXPay', 'openProductSpecificView', 'addCard', 'chooseCard', 'openCard' ] // 必填,需要使用的JS接口列表,所有JS接口列表見(jiàn)附錄2。詳見(jiàn):http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html }); wx.error(function (res) { console.log(res); alert('驗(yàn)證失敗'); }); wx.ready(function () { var url = 'http://weixin.senparc.com'; var link = url + '@(Request.Url.PathAndQuery)'; var imgUrl = url + '/images/v2/ewm_01.png'; //轉(zhuǎn)發(fā)到朋友圈 wx.onMenuShareTimeline({ title: 'JSSDK朋友圈轉(zhuǎn)發(fā)測(cè)試', link: link, imgUrl: imgUrl, success: function () { alert('轉(zhuǎn)發(fā)成功!'); }, cancel: function () { alert('轉(zhuǎn)發(fā)失??!'); } }); //轉(zhuǎn)發(fā)給朋友 wx.onMenuShareAppMessage({ title: 'JSSDK朋友圈轉(zhuǎn)發(fā)測(cè)試', desc: '轉(zhuǎn)發(fā)給朋友', link: link, imgUrl: imgUrl, type: 'link', dataUrl: '', success: function () { alert('轉(zhuǎn)發(fā)成功!'); }, cancel: function () { alert('轉(zhuǎn)發(fā)失??!'); } }); }); </script> </head>
- ?? ??? Helper:
public class JSSDKHelper { public JSSDKHelper() { Parameters = new Hashtable(); } protected Hashtable Parameters; /// <summary> /// 設(shè)置參數(shù)值 /// </summary> /// <param name="parameter"></param> /// <param name="parameterValue"></param> private void SetParameter(string parameter, string parameterValue) { if (!string.IsNullOrEmpty(parameter)) { if (Parameters.Contains(parameter)) { Parameters.Remove(parameter); } Parameters.Add(parameter, parameterValue); } } private void ClearParameter() { Parameters.Clear(); } /// <summary> /// 獲取隨機(jī)字符串 /// </summary> /// <returns></returns> public static string GetNoncestr() { Random random = new Random(); return MD5Util.GetMD5(random.Next(1000).ToString(), "GBK"); } /// <summary> /// 獲取時(shí)間戳 /// </summary> /// <returns></returns> public static string GetTimestamp() { TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0); return Convert.ToInt64(ts.TotalSeconds).ToString(); } /// <summary> /// sha1加密 /// </summary> /// <returns></returns> private string CreateSha1() { StringBuilder sb = new StringBuilder(); ArrayList akeys = new ArrayList(Parameters.Keys); akeys.Sort(); foreach (string k in akeys) { string v = (string)Parameters[k]; if (sb.Length == 0) { sb.Append(k + "=" + v); } else { sb.Append("&" + k + "=" + v); } } return SHA1UtilHelper.GetSha1(sb.ToString()).ToString().ToLower(); } /// <summary> /// 生成cardSign的加密方法 /// </summary> /// <returns></returns> private string CreateCardSha1() { StringBuilder sb = new StringBuilder(); ArrayList akeys = new ArrayList(Parameters.Keys); akeys.Sort(); foreach (string k in akeys) { string v = (string)Parameters[k]; sb.Append(v); } return SHA1UtilHelper.GetSha1(sb.ToString()).ToString().ToLower(); } /// <summary> /// 獲取JS-SDK權(quán)限驗(yàn)證的簽名Signature /// </summary> /// <param name="ticket"></param> /// <param name="noncestr"></param> /// <param name="timestamp"></param> /// <param name="url"></param> /// <returns></returns> public string GetSignature(string ticket, string noncestr, string timestamp, string url) { //清空Parameters ClearParameter(); SetParameter("jsapi_ticket", ticket); SetParameter("noncestr", noncestr); SetParameter("timestamp", timestamp); SetParameter("url", url); return CreateSha1(); } /// <summary> /// 獲取位置簽名AddrSign /// </summary> /// <param name="appId"></param> /// <param name="appSecret"></param> /// <param name="noncestr"></param> /// <param name="timestamp"></param> /// <param name="url"></param> /// <returns></returns> public string GetAddrSign(string appId, string appSecret, string noncestr, string timestamp, string url) { //清空Parameters ClearParameter(); var accessToken = AccessTokenContainer.TryGetToken(appId, appSecret); SetParameter("appId", appId); SetParameter("noncestr", noncestr); SetParameter("timestamp", timestamp); SetParameter("url", url); SetParameter("accesstoken", accessToken); return CreateSha1(); } /// <summary> /// 獲取卡券簽名CardSign /// </summary> /// <param name="appId"></param> /// <param name="appSecret"></param> /// <param name="locationId"></param> /// <param name="noncestr"></param> /// <param name="timestamp"></param> /// <param name="cardId"></param> /// <param name="cardType"></param> /// <returns></returns> public string GetCardSign(string appId, string appSecret, string locationId, string noncestr, string timestamp, string cardId, string cardType) { //清空Parameters ClearParameter(); SetParameter("appId", appId); SetParameter("appsecret", appSecret); SetParameter("location_id", locationId); SetParameter("nonce_str", noncestr); SetParameter("times_tamp", timestamp); SetParameter("card_id", cardId); SetParameter("card_type", cardType); return CreateCardSha1(); } }
WeChat ?? ?? ??? ?? WeChat JSSDK? ??? ? ?? ??? ??? ??? ???. PHP ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

Scrapy? WeChat ?? ??? ?? ??? ? ??? ?????. WeChat? ?? ? ? ?? ?? ?? ?? ??? ????????, ??? ???? ?? ??? ?? ??? ??? ???. ?? ?? ?? ??? WeChat ?? ??? ??? ??? ?????. ???? ? ?? ??? ??, ??? ??? ? ?? ??? ??? ? ?? ?????. ? ??? ????, ???? ? ??? ???? ??? ??? ? ????. ??? ? ???? Scrapy ?????? ???? WeChat ?? ?? ?? ????? ???? ??? ???????. Scr

WeChat ?? ?? ??? ???? ???? ?? ??, ?? ??, ?? ??, ????? ?? ? ??? ??? ????. ??? ??: 1. ?? ?? ??? ?? ??? ??? V ??? ?? ?? ??? ?? ???. ? ??? ?? ??? ???? ??? ??? ???? ?? ?? ?? ??? ? ?? ??? ? ?? ????. 2. ?? ??. ??? ?? ??? ??? ?? ???? ? ?? ??? ??? ????. ?? ??, ??? ?? ??? ??? ?? ? ?? ?? ?? ?? WeChat ?? ??? ???? ? ????.

Python? ??? ??? ?? ? ? ??? ??? ?? ??? ????? ?????. ??? ??? ???? ??? ?? ???? ?? ? ???, ???? ???? ?? ??? ??? ?????. ??? ??? ?? ? ???? Python ???? ?? ?????. ? ????? Python ???? ???? WeChat ?? ?? ?? ??? ?? ??? ?????. WeChat ?? ??? ???? ??? ???? ?? ?? ?? ??? ????? ?? ??? ?? ???? ?? ? ???? ?? ??? ?????.

??? ??? ??? WeChat ?? ??? ?? ? ?? ??? ??? ??? ??? ?????. WeChat ?? ??? ? ?? ??? ????? ?? ?????? ???? ?? ??? ????. ? ????? PHP ??? ?? ?? WeChat ?? ?? API ?????? ???? ??? ?????. 1. ?? WeChat ?? ?? API ?????? ???? ?? ???? WeChat ?? ?? ??? ???? WeChat ?? ????? ??? ????? ??? ???? ???. ??? ????? ???? ?? ??? AppID ? AppSe? ?? ? ????.

Laravel? ???? WeChat ?? ??? ???? ??? ?? ???? ???? ?? WeChat ?? ??? ?? ???? ?? ?? ? ?? ??? ?? ??? ???? ??? ??? ???? ??????. ???? ???? WeChat ?? ??? ???? ? ??? ?? ???? ???? ??? ???? ??? ???? ? ????. ? ???? Laravel ?????? ???? ??? ???? ???? ??? ???? ???? ?? ??? ?????. ???? ?? ?? ?? ??? Laravel ?????? ???? ??? ???? ???. ???

?? ??? ??? ??? ??? ??? ? ?? ?? ??? ??? ?? 8?? ??? ??? ? ????. ?? ??? ???? ??: 1. ??? "?? ??"? ??? ? "? ??? ? ??? ??"? ?????. ? ?? ?? ??? ?????. 2. ? ?? ??? ??? ? ?? ? ?? ?? ??? ?? + ??? ???? "??? ???"? ???? ? ?? ??? ?????. 3. ?? ???? ???? ??? ? "??"? ?????. ???? ???'? ???? ?? ??? ??? ?????.

???? ??? ??? ??? ???? ???? ?? WeChat ?? ??? ?? ???? ???? ?? ??? ?????. WeChat ?? ??? ?? ??? ???? ?? ??????, ??? ???? ????, ??? ???? ?? ? ????. WeChat ?? ?? ??????? ? ? ???? ?? ?? ? ?? ???? ??? Go ??? ???? WeChat ?? ?? ??????? ????? ???? ????. Go ??? Google? ??? ????? ???, ??? ???? ???, ???? ??? ??? ??????? ???? ? ?????. ?? ??? ????

8? 1? ? ????? ??? ???, ?? ?? ??? ?? ??? ?? ??? ??????. ?????? ???? ??? ?? ??? ??? ??? ???? ?? ??, ??, ?? ? ?? ??? ??? ?? ??? ??? ???? ??? ????? ??????. ??? ??? ????? ??? ??????? ???? ??? ? ???? ?? ????. WeChat? ???? ??? ????, ?? ???? ???? ???? ?? ??? ?? ?? ??? ?? ????. ? ???? ??? ????? ??? ??? ??? ??, ??, ??, ?? ??? ???? ?? ??? ??? ???? ??? ???? ?? ????. ▲?? ?? ?? ?? ??? ????, ?? ?? ???? ?, ?, ? ? ??? ??? ?? ???? ???? ???, ??? ??, ?? ???? ?? ? ?? ??? ???? ??. ?? ??? ??? ???? ???? ????? ???? ???? ??
