ReceivedSms.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. $temp = explode("$$$", $arr[1]);
  21. $result[] = [
  22. 'from' => $temp[1],
  23. 'to' => $temp[2],
  24. 'msg' => $temp[0]
  25. ];
  26. }
  27. }
  28. $this->showSuccess($result);
  29. }
  30. protected function postData()
  31. {
  32. Logger::setLog(file_get_contents("php://input"), APP_DIR . "/test_msg.txt");
  33. }
  34. protected function putData()
  35. {
  36. // TODO: Implement putData() method.
  37. }
  38. protected function deleteData()
  39. {
  40. // TODO: Implement deleteData() method.
  41. }
  42. }