MsgForwardServer.php 934 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Mead
  5. * Date: 2019/9/3
  6. * Time: 8:05 PM
  7. */
  8. namespace App\Servers;
  9. class MsgForwardServer extends BaseServer
  10. {
  11. public function main($body)
  12. {
  13. $data = $this->decode($body);
  14. self::log($data, 'MsgForwardServer', self::$LOG_MAJOR);
  15. return false;
  16. }
  17. /**
  18. * 解析装载的数据
  19. * @param $body
  20. * @return array
  21. * User: Mead
  22. */
  23. private function decode($body)
  24. {
  25. $i = 0;
  26. $box_no = self::stitching($body, $i, 5);
  27. $i += 5;
  28. // 短信发送者的号码
  29. $mobile = self::stitching($body, $i, 10);
  30. $i += 10;
  31. // 短信内容
  32. $body = self::stitching($body, $i, false);
  33. // 处理值
  34. $box_no = $this->decodeBoxNo($box_no);
  35. return [
  36. 'box_no' => $box_no,
  37. 'mobile' => $mobile,
  38. 'body' => $body
  39. ];
  40. }
  41. }