0

Can anybody tell me how to get the response data from a push notification response. I am currently only able to get data from headers, but $_POST is an empty array. Can anybody push me in the right direction? (I get notifications from google and outlook.)

My notifications file contains code as below:

header('Content-Type: text/html; charset=utf-8');
header("HTTP/1.1 200 OK");
file_put_contents('response-data.txt', serialize($_POST));
NIKO_B
  • 189
  • 1
  • 2
  • 9
  • What format are those notifications send in - JSON? If so: Possible duplicate of https://stackoverflow.com/questions/18866571/receive-json-post-with-php – misorude Oct 10 '18 at 12:35
  • Thanks for the reply. I see that my question resembles the one you link to. But as i can see, he didn't get his problem resolved. – NIKO_B Oct 10 '18 at 12:53

1 Answers1

1

try something alike:

file_put_contents('response-data.txt', file_get_contents('php://input'));
Martin Zeitler
  • 1
  • 19
  • 155
  • 216
  • Thanks for the answer. Using file_get_contents('php://input') return empty as well. – NIKO_B Oct 10 '18 at 12:50
  • @NIKO_B would assume, there is no post ...what do the httpd logs say? are you certain that this postback-receiver script can be accessed without having to login? – Martin Zeitler Oct 10 '18 at 12:53
  • @NIKO_B this depends on the server; ordinary it's something alike `/var/log/httpd/access_log` or `/var/log/httpd/error_log` - on shared hostings, one may find them in the hosting console. – Martin Zeitler Oct 10 '18 at 12:58
  • Thanks. I found them. The logs don't report any errors. Only 200. @martin-zeitler – NIKO_B Oct 10 '18 at 13:09