-
Notifications
You must be signed in to change notification settings - Fork 317
wechat_jsapi
TMs edited this page Nov 14, 2016
·
9 revisions
use Thenbsp\Wechat\Wechat\Jsapi;
$jsapi = new Jsapi($accessToken);
$jsapi->setCache($cacheDriver);
$jsapi
->addApi('onMenuShareTimeline')
->addApi('onMenuShareAppMessage');
也可以使用数组:
$jsapi->addApi(array('onMenuShareTimeline', 'onMenuShareAppMessage'));
$jsapi->enableDebug();
Jsapi::getConfig()
方法默认返回 JSON
字符串,可以直接传递给前端:
$json = $jsapi->getConfig();
如果需要返回 array
,可将第二个参数设为 true
:
$array = $jsapi->getConfig(true);
前端 wx.config()
中可以直接输出 $jsapi
对象:
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
wx.config(<?php echo $jsapi; ?>);
</script>
如果弹出 {"errMsg": "config:ok"} 说明配置成功!