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


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

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

    image
    服务端获取微信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获得微信接口权限成功
    image

    /*
    微信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);
    
  • 相关阅读:
    真正VC++.net笔记1系统时间的获取
    真正VC++.net笔记5MessageBox变MessageBoxA?
    Judge Online 系统流程设计
    杂谈1:事情因每个人的参与而不同
    ESX/ESXi 4.1 Update 1 or later 同步NTP
    iSCSI CHAP认证
    JSTL中c:set标签的要点和技巧
    JSTL 判断对象是否为空
    Smartmontools——linux磁盘检测工具
    ECMAScript 对象类型
  • 原文地址:https://www.cnblogs.com/ylizml/p/9053033.html
Copyright © 2020-2023  润新知