ReceivedSms.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace Heanup\App\Api\Controller;
  3. use Heanup\App\Api\RestfulController;
  4. use Heanup\Frame\Logger;
  5. class ReceivedSms extends RestfulController
  6. {
  7. protected function main()
  8. {
  9. $this->showSuccess();
  10. // file_put_contents(APP_DIR . "/test_msg.txt", file_get_contents("php://input").PHP_EOL,FILE_APPEND);
  11. }
  12. protected function getData()
  13. {
  14. $data = file(APP_DIR . "/test_msg.txt");
  15. $result = [];
  16. foreach ($data as $datum) {
  17. $pat = "#\[操作:(.*)\]#iUs";
  18. preg_match($pat, $datum, $arr);
  19. if ($arr[1]) {
  20. print_r($arr);
  21. $temp = explode("$$$", $arr[1]);
  22. $result[] = [
  23. 'from' => $temp[1],
  24. 'to' => $temp[2],
  25. 'msg' => $temp[0]
  26. ];
  27. }
  28. }
  29. $this->showSuccess($result);
  30. }
  31. protected function postData()
  32. {
  33. Logger::setLog(file_get_contents("php://input"), APP_DIR . "/test_msg.txt");
  34. }
  35. protected function putData()
  36. {
  37. // TODO: Implement putData() method.
  38. }
  39. protected function deleteData()
  40. {
  41. // TODO: Implement deleteData() method.
  42. }
  43. }