wechat-jssdk-sign.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | WeChatDeveloper
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2023 ThinkAdmin [ thinkadmin.top ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: https://thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // | 免责声明 ( https://thinkadmin.top/disclaimer )
  11. // +----------------------------------------------------------------------
  12. // | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
  13. // | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
  14. // +----------------------------------------------------------------------
  15. try {
  16. // 1. 手动加载入口文件
  17. include "../include.php";
  18. // 2. 准备公众号配置参数
  19. $config = include "./config.php";
  20. // 3. 创建接口实例
  21. // $wechat = \We::WeChatScript($config);
  22. // $wechat = new \WeChat\Script($config);
  23. $wechat = \WeChat\Script::instance($config);
  24. // 4. 获取JSSDK网址签名配置
  25. $result = $wechat->getJsSign('https://a.com/test.php');
  26. var_export($result);
  27. } catch (Exception $e) {
  28. // 出错啦,处理下吧
  29. echo $e->getMessage() . PHP_EOL;
  30. }