phpfacebookfacebook-graph-api

Get Facebook id of person how tagged me on my timeline


Currently i'm working on a website for a client. I want to show his latest Facebook wall posts on his website, also posts he is tagged in by others. With the Facebook Graph i can get allot of data from the latest post like message, description, picture etc. But i just can't find or get the Facebook id of the person who tagged him in that post... Only his own Facebook id and the id's of the others persons who where tagged, but not the tagger (if that is even a word :P)

Can anybody help me with this?

I'm using /feed in the Facebook Graph to get the data from the posts on his wall

$fb_id = 'your-facebook-id';
$fb_token = 'my-acces-token'; // tokken obtained from Facebook graph explorer page

$fb_response = file_get_contents('https://graph.facebook.com/'.$fb_id.'/feed?access_token='.$fb_token);
$fb_array = json_decode($fb_response, true);

Thanks for your time!!


Solution

  • If I understand you correctly, you just need to find the ID of a user that posted a status update that tagged your client.

    Do things as you were before, by collecting objects from the /user/feed edge. You should retrieve an ID for the status. With this, make another call to the Graph for /STATUS_ID. This will give you information about who posted the status along with other things.

    https://developers.facebook.com/docs/graph-api/reference/v2.1/post

    Note that this will only work for public posts with any valid access token. If the post is not public, you may not be able to retrieve the post with a user's access token that is not the original user who posted the status. Keep in mind that the docs specifically state:

    Only posts whose authors have also granted read_stream permission to the app will be shown for /user/feed.