Get multiple users from facebook open graph with one call - facebook

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...

Related

get all the friends and all mutual friends with graph-api

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

Facebook Friends in each Friendlist

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 ;)

Why does my facebook friendlist request doesn't show as many friends as on my profile?

I'm trying to get my users friends lists by using the facebook graph API doing so:
FB.api('me/friends', function(response) {
console.log(response);
user.friends = response;
});
When I test on my own profile I get 95% of my fb friends (583 friends instead of the 602 I can see on my profile). Thus, I see in the response object there is a "next" url for the pagination function which doesn't return anything when triggered. Why is this happening ? Where does that possibly come from ?
Thanks
If you have a problem with next URL for the pagination, try using the offset and limit parameters in the URI.
For example, instead of making an API call to me/friends, make a call to me/friends?limit=100&offset=0. This will start the list of your friends from an offset of 0 and will display a list of 100 friends on on each page. The next URL will work just fine in this case. You can however increase the limit of the users per page.

In terms of privacy, is it acceptable to extract the user id from a Facebook share response to make use of that user's details?

Using the Facebook API, you can get back the post ID of a Facebook share, even if the user has not authorized your app.
The post ID is prefixed by your user ID, and separated by an underscore.
FB.ui({
method: 'feed',
name: 'People Argue Just to Win',
link: 'http://www.nytimes.com/2011/...',
}, function( response ){
// Response gives you :
// { post_id: "[fbUserId]_346759642059572" }
});
To me it looks like Facebook is using this programmatically, rather than with the idea of providing us the userId out of the kindness of their hearts. But it's extremely tempting to use.
I'm a little rusty on permissions - if there is a way to get back all the users that have liked/shared a specific URL, and not just a count, then this should be okay.
But the question remains, is it acceptable to use?
EDIT:
Now that I think about it, you can access the user ID by making an anonymous call to https://graph.facebook.com/[postId] but ONLY if the post was made public.
If you get a response from FB, it means that you have already ask the user for the required permissions,
so yes you can use the data returned from Facebook as you like, but you always have to inform the users how you use those data.
You can only cache user data if you have permission or it is necessary for the function of your app. Using the like button you can subscribe to edge.create and cache the response from the like.
refer to: http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/
II. Storing and Using Data You Receive From Us
You will only request the data you need to operate your application.
You may cache data you receive through use of the Facebook API in
order to improve your application’s user experience, but you should
try to keep the data up to date. This permission does not give you any
rights to such data.
in my app i store the id of every page or user that is viewed to speed up page load times and count page views. Seems with in the scope of Policy as long as i am not sharing the info with 3rd parties or making public what a user has set to non public.

Facebook graph API 'friends' request now only returning 25 friends per page? What's going on?

My application(game) has been running on Facebook for some time. I start by requesting a friends list via the graph API call: my-uid/friends
asking for user name and profile pic.
Normally I get back a list of all my friends up to a few thousand, until it starts putting friends on to the next page. Which is nice as most of my users get friends in 1 call.
Suddenly however, and with no changes to the app. about 40 minutes ago (18:40 Tuesday (PDT) - 2nd May 2012) I started getting responses with only 25 friends per 'page'!
I can still get my whole friends list using multiple calls, but the game is not currently set up to do that properly. Can anyone tell me why the sudden change? Anyone else seen similar problems and how do I get the list to give me up to 5000 friends per page like it used to.
Reproducible using the Graph API Explorer
I don't know what else to tell you; perhaps the default number returned has changed, but when I try, a call to /me/friends?limit=5000 returns the full list for me (but my friends list is >500 and < 1000 , so maybe it cuts off somewhere along the way)
(Side note: the average number of friends has been found to be ~190 so presumably most users will have less than 500 anyway, and having to page above 500 would be an edge case
In SDK 4.7 you need to pass in a bundle with the number of friends you want to return, I have set it to 5000 as this is the maximum number of friends you can have on Facebook.
You also need to set up your app as a game in the facebook dev console and use invitable friends to get a full friends list
Create your bundle
Bundle bundle = new Bundle();
Add params to your bundle
bundle.putInt("limit", 5000);
Then pass it in to your GraphRequest
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/me/invitable_friends",
bundle,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
//Do something with the response
}
}
).executeAsync();
It seems that facebook changed its limit to 25 results in other api calls too (feed, posts, friends, etc), if you request friends without parameters the JSON response shows the following:
"paging": {
"next": "https://graph.facebook.com/USER_ID/friends?format=json&limit=25&offset=25&__after_id=LAST_ID"
}
Anyway you could/should always set limit & offset parameters to prevent this kind of things, limit = 0 will return all your friends list.
https://graph.facebook.com/USER_ID/friends?limit=0
If you are only requesting friends from a normal user the maximum number allowed is 5,000 so the limit should could be either 0 or 5,000 if you are requesting info from a facebook page or other kind of api calls like posts or feed this limit could increase or decrease.
(Update) Facebook fixed this bug so setting limit to 0 returns 0 friends, you should set a positive limit, thanks Dinuz
I think the best thing you can do is to add limit=5000 parameter as Igy says.
However I posted a bug report since this change wasn't noticed or described in the document.
The number of results returned from the /v2.2/me/friends endpoint now defaults to 25.
Friend list now only returns friends who also use your app: The list of friends returned via the /me/friends endpoint is now limited to the list of friends that have authorized your app.
See Facebook changes
Facebook API change log
If you are using GraphRequest() (e.g. in React Native), you can put it directly in the string field, like so :
new GraphRequest(
'/me',
{
accessToken,
parameters: {
fields: {
string: 'id,email,first_name,last_name,friends.limit(5000)'
}
}
...