How can I get a list of friends along with their friend_list_type?
I tried to get all the list_types by making the following call:
https://graph.facebook.com/[USER_ID]/friendlists?access_token=ACCESS_TOKEN
On receiving this, I tried ti iterate over the list_types and make the following call to get the list of friends on each list_type:
https://graph.facebook.com/[FRIEND_LIST_ID]/members?access_token=ACCESS_TOKEN
But, I always get an empty array in response, like this:
{
"data": [
]
}
I am sure that the user is having friends mapped to multiple friend_list_types. But, still I am getting NO result. Is there anything which I am not aware of?
Note that, I tried this on all versions of Facebook Graph API and I also have read_friendlists permission to access the user's friend_list.
The friendlists endpoint is only a list of the friendlists, there is no way to get the friends in those friendlists.
Think of it this way: What if someone creates a list called "Idjits" and puts some friends in it. No App should be allowed to read that kind of information ;)
Related
I'm trying to get all friends of a user, and mutual friends. I'm using Graph API V2.4.
first I used ... /me/friends but i discover this method return only friends with use my app. I read that is used .../me/taggable_friends and returned all friends, but not return id friend, return other id.
I read about all_mutual_friends but I cannot use this method because i dont have friend ids.
Anybody know any solution ?
Unfortunately there's no workaround for this , you can't access a user's friends list .
However if you can access his news feed you can iterate over his posts and get the json array of the likes of each one and combine them , by doing this you at least have some of the user's friends IDs .
The request goes something like this
Get /{post id}?fields=likes
I am facing a problem in fetching the friends of a user. The following code is working fine when "me" is passed as an UID. But it doesn't work when a user id is passed like 523621551. Every thing is set in the permissions. And i get the "Unsupported operation" error. Following is the code.
public function getAllFriends($uid) {
return $this->fb->api("/" . $uid . "/friends", 'GET', array(
'access_token' => $this->fb->getAccessToken())
);
}
So, what is causing this problem?
I also studied other related questions but those didn't help. :(
You can´t get the friends of ANY user, you can only get the friends of the user who is authorized at the moment. The docs are a bit misleading, it may only work with the (app scoped) user id of the authorized user, but it will never work with any other user id - that request is "unsupported" ;)
Also, you can only get the users who authorized the same App too, just in case you don´t know yet. See changelog: https://developers.facebook.com/docs/apps/changelog
Edit: I just tested it with an App Scoped ID in the API Explorer and it works, so i assume you are trying to get the friends of another user as i expected - which is not supported, of course.
I also tested it with the "real" ID of the authorized user and got the following error:
The global ID 1603196280 is not allowed. Please use the application
specific ID instead.
Makes sense, you would not get the global ID in the App anyway, only App Scoped IDs. As i said, the error you get is not very clear but correct: Getting the friends of ANY user is "unsupported".
Calling this URL return a user object with public informations about a facebook user:
https://graph.facebook.com/100000050972893
100000050972893 is the facebook user ID. Is it possible to get multiple user objects with one call? I need to know the gender of about 200 users and I dont think its a good idea calling 200 times the graph URL...
Just found the answer:
https://graph.facebook.com/?ids=100000050972893,100000953354280
But I dont know where the Limit of IDs is you can check with one call...
I'm trying to get all the data the logged-in user / one of his friends posted on FB.
I'm currently doing three different calls to:
/<username I want data for>/links
/<username I want data for>/photos/uploaded
/<username I want data for>/statuses
This works just fine for many users. However, some users are returning an empty result ({
"data": [
]
}). When trying to debug I'm noticing that a call to /username/feed is returning results which some of them are links / photos / statuses.
How can this be? Am I calling the wrong endpoints?
This is the relevant API page FB User Object
you are getting data for your account. Please try to reproduce the same on different browser.
(check the same thing on IE)
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?
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 :)
I've been wrestling with this all day myself and I believe I have figured it out, nowhere in facebook documentation (that I have found) is this clear. And I don't believe the other answers actually answered your question, it looks like you requested permissions correctly. Anyway, to request the information you are looking for, ping the api like this:
https://graph.facebook.com/userid/friends?fields=work&access_token=ACCESSTOKENHERE
This will return you all the friends' info in one long JSON response.
It is a little confusing because the permissions you are asking for are not the same thing you need to query the API.
The query above will return the friends' ids with work history. You can add commas to the fields parameter to include additional info like name, but then the API calls/responses end up taking a long time.
http://developers.facebook.com/docs/reference/api/user/
you can get all the fields mentioned here .To get work you need to have user_work_history or friends_work_history permission
in the link it is mentioned what permissions to obtain before you get the info and another thing that user has to allow your application,this will make your app to get the informations.
From this answer to another question: a call to 'me/friends?fields=work' worked for me!
I'd suggest that you go to http://developers.facebook.com/docs/reference/api/user/ like most of the others are suggesting but as a general tip, use the friends_education_history as a way to get the friend's history.
P.S: Minor spelling error in your original question that should be edited. "education_histroy." = education_history
in the second line of your main paragraph.
You can use this code you will get name, profile picture, ID of your friends.
FB.api('/me/taggable_friends', function(response) {
for (var i = 0; i < friend_data.length; i++) {
results += ''+friend_data[i].name;
}
});
Before that in your developer account created app-> go to tools and support->graph API explorer-> click Get Token. In that window click user_tagged_places and click Get Access Token. You will get your friends list.