1

I need to know how to have PHP Storm catch a HTTP POST request when a remote service sends a request to my server. Background:

I am using an SMS service called Clickatel. When a customer responds to a sms message, Clickatel sends a response to a script I wrote called sms_response.php. The problem I am running into is I don't know the contents of what they are sending. I want to catch the POST request using PHP debugging. Ideally, I can see the entire message. I know the script I wrote is getting called because it logs a hard coded message to a logfile. I am having trouble reading the contents because I don't know the variables being sent.

Maybe an easier question is this: How can I parse all the contents of a HTTP POST when I don't know the names of the variables. The $_POST and $_GET variables appear to be empty. I've also tried printing the values of the $_SERVER variable using a foreach loop, but that seems empty too.

Any ideas? What am I brain-flutzing about?

1 Answers1

1

Ok. I found out the answer. It took a little bit but I realized I over looked a few things.

1) My original code was using PHP 5.6. I was catching the code using $HTTP_RAW_POST_DATA, but that was depreciated when PHP 7.0 came out.

2) To get the contents of the response, I had to use file_get_contents("php://input");

If this helps, I used the following code to see the response. Now I know the contents and I know how to get the data so I can parse it, this might help.

$text = file_get_contents("php://input");
$textfile = "/var/www/html/openemr-500/sms.log";
$myfile = file_put_contents($textfile, $text.PHP_EOL , FILE_APPEND | LOCK_EX);

The response is a json string that I already know how to parse. Hopefully this helps people.