R – Facebook Graph API – get friends info

facebookfacebook-graph-api

I'm trying to figure out how to get users friends information using either Graph API or FQL

Just for testing I would like to get my friends education_histroy.

To do that I created a test app, requested extended permissions using

scope=offline_access,manage_friendlists,friends_work_history,
      friends_education_history,friends_about_me

and got access token to play with the API.

It works great when I query for current user using /me. But it returns nothing for my friends.

I was assuming that if I request, let's say friends_work_history, that extra field (work_history) will appear inside friend's object, when I query by friend's id:

https://graph.facebook.com/FRIEND_ID&access_token=TOKEN

But all I see is basic info about that user (friend).

Then I tried to request that field specifically:

https://graph.facebook.com/FRIEND_ID?fields=work&access_token=TOKEN

With no luck again. Returns just friend's id..

I tried to access that information with FQL:

https://api.facebook.com/method/fql.query?query=select+work_history+from+user+where+uid+in+(FRIEND_ID)&access_token=TOKEN

Returns work_history = TRUE instead of array. And that friend definitely has work history specified.

Can someone help me to understand how to get friends info using my app and extended permissions?

Best Answer

Graph API is the smart choice in most cases. To retrieve your friend information you need to collect some extended permissions from the user first. Then you can retrieve a lot more information other than the basic ones.

Following is a list of extended permissions related to friends different kind of information

friends_about_me        
friends_activities      
friends_birthday
friends_checkins        
friends_education_history       
friends_events
friends_games_activity      
friends_groups      
friends_hometown
friends_interests       
friends_likes       
friends_location
friends_notes       
friends_online_presence     
friends_photo_video_tags 
friends_photos      
friends_relationship_details        
friends_relationships
friends_religion_politics       
friends_status      
friends_subscriptions
friends_videos      
friends_website     
friends_work_history

Hope it helps :)