Pergunta

I am trying to receive realtime updates from Facebook using their Realtime Updates API. I am just trying to get updates of the user's feed. I am using PHP to do all of this. I have it setup and verified, but I cannot access the response when they send it to my callback url. Is there a way to retrieve the json that is being sent to my callback url?

Foi útil?

Solução

From the docs:

The request will have content type of application/json and the body will comprise a JSON-encoded string containing one or more changes.

This means you can not access it in PHP using the “normal” way of accessing values in $_POST, because this request is not of the format form/urlencoded – it does not contain name=value pairs, but instead is in itself just a JSON-encoded string.

You should be able to read this data using the php://input stream wrapper – for example by simply using a line like

$inputdata = file_get_contents('php://input');

– and then you just use json_decode on the contents of this variable.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top