Serve.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Niucloud-admin 企业快速开发的saas管理平台
  4. // +----------------------------------------------------------------------
  5. // | 官方网址:https://www.niucloud.com
  6. // +----------------------------------------------------------------------
  7. // | niucloud团队 版权所有 开源版本可自由商用
  8. // +----------------------------------------------------------------------
  9. // | Author: Niucloud Team
  10. // +----------------------------------------------------------------------
  11. namespace app\api\controller\wechat;
  12. use app\service\api\wechat\WechatServeService;
  13. use core\base\BaseController;
  14. use EasyWeChat\Kernel\Exceptions\BadRequestException;
  15. use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
  16. use EasyWeChat\Kernel\Exceptions\RuntimeException;
  17. use ReflectionException;
  18. use Symfony\Component\HttpFoundation\Response;
  19. use Throwable;
  20. /**
  21. * 微信服务端通信以及网页授权
  22. */
  23. class Serve extends BaseController
  24. {
  25. /**
  26. * 接收消息并推送
  27. * @return Response
  28. * @throws BadRequestException
  29. * @throws InvalidArgumentException
  30. * @throws RuntimeException
  31. * @throws ReflectionException
  32. * @throws Throwable
  33. */
  34. public function serve(){
  35. ob_clean();
  36. $result = (new WechatServeService())->serve();
  37. return response($result->getBody())->header([
  38. 'Content-Type' => 'text/plain;charset=utf-8'
  39. ]);
  40. }
  41. }