微信开发+百度AI学习:微信网页开发环境搭建 您所在的位置:网站首页 github搭建网页 微信开发+百度AI学习:微信网页开发环境搭建

微信开发+百度AI学习:微信网页开发环境搭建

2023-03-04 16:30| 来源: 网络整理| 查看: 265

参考微信官方文档:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115 两步即可获取微信网页开发能力

STEP1:安装微信公众号开发nuget,里面封装了微信开发所需要的所有接口

服务端获取微信JS-SDK签名

public JsonResult GetJsApi(string url) { string timestamp = JSSDKHelper.GetTimestamp(); string nonceStr = JSSDKHelper.GetNoncestr(); string ticket = Senparc.Weixin.MP.Containers.JsApiTicketContainer.TryGetJsApiTicket(ApiConfig.AppID, ApiConfig.AppSecret); string signature = JSSDKHelper.GetSignature(ticket, nonceStr, timestamp, url); return Json(new { appId = ApiConfig.AppID, timestamp, nonceStr, signature }, JsonRequestBehavior.AllowGet); }

STEP1:页面调用js获得微信接口权限成功

/* 微信jsAPI */ (function ($, navigator) { var ant_js_config; var init_ant_js = function () { wx.config({ debug: false, appId: ant_js_config.appId, timestamp: ant_js_config.timestamp, nonceStr: ant_js_config.nonceStr, signature: ant_js_config.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' ] }); } $.getJSON('/common/GetJsApi', { 'url': window.location.href }, function (result) { if (result) { ant_js_config = result; init_ant_js(); } }); })(jQuery, navigator);


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

      专题文章
        CopyRight 2018-2019 实验室设备网 版权所有