2

I want to retrieve user's music likes from Facebook. I have subscribed to realtime updates and appropriate permissions are set in the App itself.

I am using facebook's UI to set permissions and Realtime updates

  1. Set "User & Friend Permissions" permissions in facebook App.

    • email
    • user_interests
    • user_likes
    • user_location
    • friends_interests
    • friends_likes
    • friends_location
    • user_actions.music
    • friends_actions.music
  2. Set desired values for realtime updates.

    • music
    • likes
    • interest
    • current_location
    • checkins

Code for my callback URL is :

$myverify_token = 'vt1';
if($_SERVER['REQUEST_METHOD'] == 'GET') {
    if($_GET['hub_verify_token'] == $myverify_token) {
    $handle = fopen('f_d.txt', 'w');
    fwrite($handle, 'FaceBook can GET me');
    fclose($handle);

    echo $_GET['hub_challenge'];
    }
}
if($_SERVER['REQUEST_METHOD'] == 'POST') {
    $data = file_get_contents("php://input");
    $json = json_decode($data);

    $handle = fopen('f_d.txt', 'w');
    fwrite($handle, $json);
    fclose($handle);
}

f_d.txt has 777 permissions set.

When I test mycallback URL the GET conditions is true and 'FaceBook can GET me' is written to file. Now I clear the contents of file (NOT Delete).

Now I login to my facebook, make changes to music likes. Waited all day still no push from Facebook. The file is still blank. Not even GET request to my callback URL ??

What else do I need to get proper Realtime updates ?

Posted on facebook : https://developers.facebook.com/bugs/394779173962716

Manmohan Bishnoi
  • 791
  • 13
  • 37

1 Answers1

0

I notice that you are trying to write the response inside a text file, which is OK, but you do it after decoding the json. This means you are writing the contents of the resulting object. The file will be created, but the actual writing will result in a fatal error leaving you with an empty file.

Long story short: Remove the json_decode command, so you can write the actual string (even though it's json encoded it's short and simple enough for you to read it).

Martini
  • 166
  • 1
  • 7