Api.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Think.Admin
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://think.ctolog.com
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | github开源项目:https://github.com/zoujingli/Think.Admin
  12. // +----------------------------------------------------------------------
  13. namespace app\wechat\controller;
  14. use handler\WechatHandler;
  15. use think\Controller;
  16. /**
  17. * 微信接口控制器
  18. * Class Api
  19. * @package app\wechat\controller
  20. * @author Anyon <zoujingli@qq.com>
  21. */
  22. class Api extends Controller
  23. {
  24. /**
  25. * 微信消息接口
  26. * @return string
  27. * @throws \Exception
  28. */
  29. public function index()
  30. {
  31. if (!extension_loaded('soap')) {
  32. throw new \Exception('Not support soap.');
  33. }
  34. $handler = new WechatHandler();
  35. $service = new \SoapServer(null, ['uri' => 'api', 'trace' => 0]);
  36. $service->setObject($handler);
  37. $service->handle();
  38. }
  39. }