-2

How to get the response from an SMS gateway (in general) in a site?

Mark
  • 7
  • 4
  • Please update your question with the relevant `php` code you are using. Also what is the expected output and what is the actual result. – Alex Andrei Jul 04 '16 at 13:53

1 Answers1

0

The documentation for the SMS gateway should describe how the data is presented via HTTP; the format will be specific to the SMS gateway, there is no standard.

Is the gateway maintained by a third party? If its one you installed yourself then how it presents the information may be part of its configuration and the issue is off topic here.

Assuming the gateway is correctly configured, you can see all the data presented by the gateway in $_REQUEST. In some (very obscure) cases the data may be presented in a raw post.

Just capture the full request to see how the data is being presented. This is easiest if the PHP is running as mod_php in Apache (you did not say) where you do this:

<?php
$log=tempnam("/tmp", 'mo_sms');
$output="started " . date('r') . "\n";
$headers = apache_request_headers();
foreach ($headers as $header => $value) {
   $output.="$header : $value\n";
}
$output.="\n";
while (!feof(STDIN)) {
   $output.=fgets($TDIN);
}
file_put_contents($log, $output);

Note that this probably does not complete the transaction with the gateway - it will likely be expecting some sort of acknowledgement that the data has been delivered successfully (but may treat a HTTP 200 as such).

symcbean
  • 47,736
  • 6
  • 59
  • 94