this is my first question to stackoverflow, so if's something wrong please advise.. Well the problem is Facebook real time updates : I have successfully created subscription to page and it's admin user ( test page and test app created ), user has agreed permissions to manage_page, read_stream, read_friendlist, read_insights,publish_actions and a lot of user's data ( about,email etc etc ) When i query GET to Graph api with edge /subscriptions i get the result :
{
"data": [
{
"object": "user",
"callback_url": "LIVE_CALLBACK_URL",
"fields": [
"feed"
],
"active": true
},
{
"object": "page",
"callback_url": "LIVE_CALLBACK_URL",
"fields": [
"built",
"description",
"email",
"feed",
"location",
"name",
"personal_info",
"written_by"
],
"active": true
}
]
}
So, that's taken care of, after that i searched why Facebook isn't sending me any updates ( which I log to somefile.txt ) So i found out you need to query the Graph api with /tabs to create page tab for my api. When i query that it returned "success" so that's created ( can't find out where it's stored, but it working ... ). After that i have created some data on my profile, to test and also on the page to see if the Facebook is sending any updates, and it's suddenly send one update that was comment on my user profile post ( shared on timeline ). The response was :
14:17 05.02.2015
Array
(
[object] => user
[entry] => Array
(
[0] => Array
(
[uid] => ****my_fb_id****
[id] => ****my_fb_id - not_someone_else****
[time] => 1423146339
[changed_fields] => Array
(
[0] => feed
)
)
)
)
So Facebook send's the empty feed, and it's ok, probably some permissions or something else, but after that i have made more posts and ppl commented on it ( on user profile and test page ) but Facebook didn't send any updates, or any call to my web page. So has anyone facing this problem in the past, and how he solved that ? The part that is for receiving the update from Facebook is :
$method = $_SERVER['REQUEST_METHOD'];
if(isset($_GET['hub_mode']) && isset($_GET['hub_verify_token'])){
if (trim($method) == 'GET' && trim($_GET['hub_mode']) == 'subscribe' && trim($_GET['hub_verify_token']) == VERIFY_TOKEN) {
print $_GET['hub_challenge'];
}
}
else if ($method == 'POST') {
$updates = json_decode(file_get_contents("php://input"), true);
$file = 'log.txt';
$current = file_get_contents($file);
@$results = print_r($updates,true);
$current .= $results;
file_put_contents($file, $current);
}
I have tried to detail my problem as much i as could... Searched but don't really understand why it's not working.
Apart from using an outdated method as @CBroe outlined, I think you have a misunderstanding: Facebook will not send you the data that has changed, but the object (and it's fields/edges) the change occurred for User object changes.
For Pages, you can receive the changes itself (changed_fields
vs. changes
fields in the FB request).
See
Once a subscription is successfully created, Facebook will make an HTTP POST request to your callback URL every time that there are changes (to the chosen fields or edges).
That means you need to contruct a separate request from the info object you get from Facebook. In your example it would be a request to your user's feed
GET /{user_id}/feed
to query for recent changes.