wechat-qrcode-create.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | WeChatDeveloper
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2020 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://think.ctolog.com
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | github开源项目:https://github.com/zoujingli/WeChatDeveloper
  12. // +----------------------------------------------------------------------
  13. try {
  14. // 1. 手动加载入口文件
  15. include "../include.php";
  16. // 2. 准备公众号配置参数
  17. $config = include "./config.php";
  18. // 3. 创建接口实例
  19. // $wechat = \We::WeChatQrcode($config);
  20. // $wechat = new \WeChat\Qrcode($config);
  21. $wechat = \WeChat\Qrcode::instance($config);
  22. // 4. 获取用户列表
  23. $result = $wechat->create('场景内容');
  24. echo var_export($result, true) . PHP_EOL;
  25. // 5. 创建二维码链接
  26. $url = $wechat->url($result['ticket']);
  27. echo var_export($url, true);
  28. } catch (Exception $e) {
  29. // 出错啦,处理下吧
  30. echo $e->getMessage() . PHP_EOL;
  31. }