mirror of
https://github.com/w7corp/easywechat.git
synced 2025-01-22 03:22:10 +00:00
Page:
JSSDK
This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
本 SDK 同样由 Overtrue\Wechat\Js
提供了 JSSDK 相关的功能。
获取实例
<?php
use Overtrue\Wechat\Js;
$appId = 'wx3cf0f39249eb0e60';
$secret = 'f1c242f4f28f735d4687abb469072a29';
$js = new Js($appId, $secret);
API
$js->config(array $APIs, $debug = false, $beta = false, $json = true);
获取JSSDK的配置数组,默认返回 JSON 字符串,当$json
为false
时返回数组,你可以直接使用到网页中。$js->setUrl($url)
设置当前URL,如果不想用默认读取的URL,可以使用此方法手动设置,通常不需要。
example:
我们可以生成js配置文件:
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
wx.config(<?php echo $js->config(array('onMenuShareQQ', 'onMenuShareWeibo'), true, true) ?>);
</script>
结果如下:
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
wx.config({
debug: true,
appId: 'wx3cf0f39249eb0e60',
timestamp: 1430009304,
nonceStr: 'qey94m021ik',
signature: '4F76593A4245644FAE4E1BC940F6422A0C3EC03E',
jsApiList: ['onMenuShareQQ', 'onMenuShareWeibo']
});
</script>
中文版 English
目录
English 中文版
Table of Contents
Laravel 5 版: overtrue/laravel-wechat
可能由于微信的接口调整导致某些接口不能正常使用,请及时给我反馈,谢谢!https://github.com/overtrue/wechat/issues