调用微信sdk

demo地址
只需要更改appid 和秘钥即可用
页面后缀都改为.php 不再是html

页面开头需要写上:

<?php
require_once "jssdk.php";
$jssdk = new JSSDK("appid", "秘钥");
$signPackage = $jssdk->GetSignPackage();
?>

script

wx.ready(function () {
   wx.checkJsApi({
        jsApiList: ['scanQRCode'], // 需要检测的JS接口列表,所有JS接口列表见附录2,
        success: function (res) {
            var result = res.resultStr;
            console.log(result)
            // 以键值对的形式返回,可用的api值true,不可用为false
            // 如:{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"}
        }
    });
    //调用其他微信sdk,都写在这个里面即可
 })
 wx.error(function (res) {
         console.log(res)
         // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
  });

猜你喜欢

转载自blog.csdn.net/weixin_43292447/article/details/86610217