WechatLogic.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace App\Http\Logic;
  3. use App\Http\Utils\LoggerFactoryUtil;
  4. use App\Http\Utils\WechatAccountUtil;
  5. class WechatLogic extends BaseLogic
  6. {
  7. /**
  8. * 校验微信服务器
  9. */
  10. public static function checkServerlogic($code)
  11. {
  12. $app = WechatAccountUtil::getApp($code);
  13. $instance = new LoggerFactoryUtil(WechatLogic::class);
  14. $app->server->push(function ($message)use ($instance,$app,$code) {
  15. $instance->info("信息:".json_encode($message));
  16. switch ($message['MsgType']) {
  17. case 'event'://事件
  18. return "欢迎关注";
  19. break;
  20. case 'text'://文字
  21. break;
  22. case 'image'://图片
  23. break;
  24. case 'voice'://语音
  25. break;
  26. case 'video'://视频
  27. break;
  28. case 'location'://坐标
  29. break;
  30. case 'link'://链接
  31. break;
  32. case 'file'://文件
  33. // ... 其它消息
  34. default:
  35. break;
  36. }
  37. });
  38. $response = $app->server->serve();
  39. return $response;
  40. }
  41. }