sms_hook_peerless.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. //includes files
  3. require_once dirname(__DIR__, 3) . "/resources/require.php";
  4. require_once "../sms_hook_common.php";
  5. //if (check_acl()) {
  6. //Make sure that it is a POST request.
  7. if(strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') != 0){
  8. throw new Exception('Request method must be POST!');
  9. }
  10. //Make sure that the content type of the POST request has been set to application/json
  11. $contentType = isset($_SERVER["CONTENT_TYPE"]) ? trim($_SERVER["CONTENT_TYPE"]) : '';
  12. if(strcasecmp($contentType, 'application/json') != 0){
  13. throw new Exception('Content type must be: application/json');
  14. }
  15. //Receive the RAW post data.
  16. $content = trim(file_get_contents("php://input"));
  17. //$mail_body.="RAW post data: ".$content."\n";
  18. //Attempt to decode the incoming RAW post data from JSON.
  19. $decoded = json_decode($content, true);
  20. $mail_body.="decoded data: \n";
  21. $sms_from=$decoded['from'];
  22. $sms_text=$decoded['text'];
  23. foreach($decoded['recipients'] as $key=>$value):
  24. $sms_to_did_no=$value;
  25. endforeach;
  26. route_and_send_sms($sms_from, $sms_to_did_no, $sms_text);
  27. // } else {
  28. die("no");
  29. // }
  30. //} else {
  31. error_log('ACCESS DENIED [SMS]: ' . print_r($_SERVER['REMOTE_ADDR'], true));
  32. die("access denied");
  33. //}
  34. ?>