Endpoint getting called, but no POST data


#1

I’m having some issues with the alerts push. I can see that FA is making a request to my set endpoint, but there is no POST data in the request.

When I call GetAlerts, I see my alert is there and appears to be well formed:



[3] => Array(
	[alert_id] => 698****
	[enabled] => 1
	[description] => Southwest 3121 (KMKE → KRSW)
	[type] => Form_Airline
	[ident] => SWA3121-1395729156-airline-0898
	[user_ident] => 
	[aircrafttype] => 
	[origin] => KMKE
	[destination] => KRSW
	[date_start] => 1395792000
	[date_end] => 1395964800
	[channels] => Array(/* ...omitted... */)
	[alert_created] => 1395956645
	[alert_changed] => 1395956645
)


My endpoint is simple:



<?php
//In a nutshell, email me all the POST data
mail ("me@example.fake.org",'FA Alert - '.time(),print_r($_POST,TRUE));
?>


The response emails I get have a blank array ($_POST was empty). If I look up the flight on flightaware.com, there definitely is a correlation between when the endpoint gets called and when the flights status changes.

Did I miss a step somewhere?


#2

For PHP, you need to look at $HTTP_RAW_POST_DATA
php.net/manual/en/reserved.v … stdata.php


#3

$_POST and HTTP_RAW_POST_DATA are the same thing. _POST is just a nice array.

I changed my email message to:
var_dump($HTTP_RAW_POST_DATA,TRUE);

//returned string (0) ""
So, it wasn’t that.


#4

Then try the stdin.

$postdata = file_get_contents(“php://input”)

Basically you need to get the raw body, since the JSON is posted directly without any HTTP FORM encoding.


#5

Bingo! Thanks for the help!