wechat-qrcode-create.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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::WeChatQrcode($config);
  22. // $wechat = new \WeChat\Qrcode($config);
  23. $wechat = \WeChat\Qrcode::instance($config);
  24. // 4. 获取用户列表
  25. $result = $wechat->create('场景内容');
  26. echo var_export($result, true) . PHP_EOL;
  27. // 5. 创建二维码链接
  28. $url = $wechat->url($result['ticket']);
  29. echo var_export($url, true);
  30. } catch (Exception $e) {
  31. // 出错啦,处理下吧
  32. echo $e->getMessage() . PHP_EOL;
  33. }