This question already has answers here:
Facebook Graph API v2.0+ - /me/friends returns empty, or only friends who also use my application
(8 answers)
Closed 8 years ago.
I'm trying to get all friends, of a user that logged into my application.
I can't use this API [friends]:
https://developers.facebook.com/docs/graph-api/reference/v2.0/user/friends
Because this API only returns any friends who have used the app making the request.
So I found this API [friendlist]:
https://developers.facebook.com/docs/graph-api/reference/v2.0/friendlist
Followed this answer, I got the friendlist list.
But I'm getting empty list when trying to get friendlist's members:
new Request(
session,
"/2692926356774/members",
null,
HttpMethod.GET,
new Request.Callback()
{
public void onCompleted(Response response)
{
/* handle the result */
Log.e(LOG_TAG,"Members: " + response.toString());
}
}
).executeAsync();
2692926356774 is my Acquaintances list id, I tried few other id's with the same result.
In v2.0 of the Graph API, calling /me/friends returns the person's friends who also use the app.
In addition, in v2.0, you must request the user_friends permission from each user. user_friends is no longer included by default in every login. Each user must grant the user_friends permission in order to appear in the response to /me/friends. See the Facebook upgrade guide for more detailed information, or review the summary below.
The /me/friendlists endpoint and user_friendlists permission are not what you're after. This endpoint does not return the users friends - its lets you access the lists a person has made to organize their friends. It does not return the friends in each of these lists. This API and permission is useful to allow you to render a custom privacy selector when giving people the opportunity to publish back to Facebook.
If you want to access a list of non-app-using friends, there are two options:
If you want to let your people tag their friends in stories that they publish to Facebook using your App, you can use the /me/taggable_friends API. Use of this endpoint requires review by Facebook and should only be used for the case where you're rendering a list of friends in order to let the user tag them in a post.
If your App is a Game AND your Game supports Facebook Canvas, you can use the /me/invitable_friends endpoint in order to render a custom invite dialog, then pass the tokens returned by this API to the standard Requests Dialog.
In other cases, apps are no longer able to retrieve the full list of a user's friends (only those friends who have specifically authorized your app using the user_friends permission).
For apps wanting allow people to invite friends to use an app, you can still use the Send Dialog on Web or the new Message Dialog on iOS and Android.
Related
I'm developing android app which integrates Facebook SDK.
I need to login - OK, done this.
I need to retrieve friends birthdays - I know it is restricted. But can it be allowed after app review?
Or how to retrieve my friends list and birthday of each friend?
Thank you.
EDIT:
It looks strange to me that when using Facebook Graph API Explorer I do friend list request (e.g. graph.facebook.com/1012984682046884/friends) I'm getting full list of my friends. But when I do the same request from android application (see code below), I'm getting result: onCompleted resp[{"summary":{"total_count":228},"data":[]}]
Here is list of permission I'm requesting during login:loginButton.setReadPermissions(Arrays.asList("public_profile", "email", "user_birthday", "user_friends"));Also, have to tell that I am admin of my FB app, I use the same FB login.
GraphRequest request = GraphRequest.newGraphPathRequest(
act,
fbuid+"/friends",
new GraphRequest.Callback() {
#Override
public void onCompleted(GraphResponse response) {
// Insert your code here
Log.d("12x17","onCompleted resp["+response.getRawResponse()+"]");
}
});
request.executeAsync();
Or how to retrieve my friends list and birthday of each friend?
By making each friend log in to your app, and having them grant your app permission to access their friends, and their birthday.
No, there is no other way. You can not get friends that are not users of the same app, and you can not get a person’s birthday unless they personally grant permission.
If your app hasn't been approved yet by Facebook to retrieve that information through the Graph API you will only be able to retrieve the information for people on your friends list that are listed as Administrators, Developers, or Testers on your Facebook app developers page. Add a trusted friend or 2 to one of those categories and you should be able to retrieve that information
I use facebook login in my app. Once the users are logged-in I can get their basic facebook info such as display name, email, and phot url.
I'd like to get their facebook friends list. I think I can get it "directly" with firebase but I don't remember how and I cannot find any info about it. I think I first have to tell Firebase to get friends list when people login with facebook, then I sould be able to get it with a method such as firebaseAuth.getCurrentUser().getFriendList().
Do you know how to get facebook friends list with firebaseAuth ?
Thank you,
Alex
It is feasible, but only the friends that also use your app. The trick is to add a scope to your login method. In Angular it looks like this
this.afAuth.auth.signInWithPopup(new firebase.auth.FacebookAuthProvider().addScope('user_friends'))
That scope at the end is the trick. Then, you need at least two users that are friends on facebook to login. You will note the popup is different as it now asks permission for the user's friends.
The response will include an access token. Then you can use that token to request the user's friends that are also using the app with a GET request like this
https://graph.facebook.com/v2.11/{facebook_uid}/?fields=friends{name,id}&access_token={access_token}
Note I'm using a particular version, but you should change that to whatever you need.
generally obtaining user's all friends list from Facebook is not possible, they removed this option years ago, with API v2.0 introduction... more info about and useful suggestions HERE
there is an official FB API called Graph API and HERE you have some doc about friend lists
and the Firebase... well, this is Google's product and it have nothing to do with Facebook... You are probably using FB mail address for creating an account in Firebase service/database, but it is keeping only this data plus some additional attributes if set (like photo or visible name).
firebaseAuth.getCurrentUser() returns FirebaseUser object, which have THESE methods - like you see: logpass, name, photo url and only few more methods. no option for getting friends list, because there is no method to set them, and no possibility to get this list from FB lib/API
Is it possible to track your Facebook notifications through an app other than Facebook's? I am looking to track the photos tagged of a person in facebook through an app.
Unfortunately, no. The Facebook sdk offers /user/notifications as an edge through the Graph API. That, however, requires the manage_notifications token which is unavailable to all Android, iOS, Web, and TV apps.
For your application, though, you're in luck (or at least I think you are). If you are trying to access all the photos of your user, you can use /user/photos to retrieve all the photos that the user is tagged in. If you follow the Reference Documentation, it'll give you back 25 photos. In order to grab more, and to 'page' through the data, use the limit and offset parameters as follows
Bundle params = new Bundle();
params.putString("limit","400");
params.putString("offset","800");
new Request( Session.getActiveSession(),
"/me/likes",
params,
HttpRequest.GET,
new RequestCallback() {
// handle results here
}
).executeAsync();
This request should give you all the information you need to know about the photo, but be sure to check out the documentation to get a list of all the fields available.
As a side note, you can also access albums to retrieve photos that the user has posted, which will also contain tagging information.
I need list of users which are using my Facebook App. So I am sending below Request.
new Request( session, "/me/friends", null, HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
...});
Fo that which permissions I need to set in facebook app?
According to Graph API user_friends permission is required. But I cant find this permission anywhere in my app.
I was using "read_friendlists" permission but FB rejected it.
Reply from Facebook Review team :
read_friendlists
Android
It looks like you're trying to use read_friendlists for something it cannot do. This permission doesn't show you a list of a person's friends.
Read_friendlists gives access to the names of custom lists a person has created to organize their friends. It will not help you invite a person's friends to use your app. To learn more about how to invite friends to an app, please see our FAQs.
Please remove "read_friendlists" from your submission. Learn more here.
The user_friends permission is the right one to use. Keep in mind that /me/friends will only return the friends which are using the same app, not all friends.
See
Get facebook friends with Graph API v.2.0
https://developers.facebook.com/docs/facebook-login/permissions/v2.2#reference-user_friends
I want to read my friends posts (feeds?, all posts but for a specific user only) from his user wall.
I need all (posts, feeds, statuses) that i see when i look at his page directly from the website.
I use the android sdk and i tried the graph api and rest method.
My app is registered and i have logged in facebook to get the access token (permission: read_stream)
but i dont get that infos that want to.
Please help.
Thx.
How about testing your Graph API call in the Graph API Explorer?
https://developers.facebook.com/tools/explorer/
In my case, I could get my first 10 friends' feed (wall) with the url https://graph.facebook.com/me?fields=friends.limit(10).fields(feed)
Note that I used field expansion of the Graph API.
http://developers.facebook.com/docs/reference/api/field_expansion/
You need them to actually use your app and grant full permissions via the graph API.
You cannot simply 'grab a friends wall'. You must do that via your app and it needs the permissions to do so from the user in question.