ReceivedSms.php 1.0 KB

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