Android Facebook SDK get friend list - android

I want to get user's who is logged into my app friend list. So, I need to use this code to do that:
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/me/friends",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();
The problem is that I don't know what I need to write into onCompleted method to put friend list to array.

after the data comes to onCompleted() you can do something like this to see the structure of the json response,
Log.d("-#-", "graph response " + response.getJSONObject());
this gives the structure of the json object from there you can get the data.
Also i think your app needs to go through facebook submission as there is other permissions your app needs to get friends of a person

Related

How can my Android app use Facebook's API to know if a user liked a post?

I did not found in documentation how can Facebook's API tell me if my user with Facebook logged, has liked a post of a specific page. Is the API of Facebook able to inform my app of such action? Maybe you can tell me?
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/{person-id}/",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();

how to get facebook friend list with emails through new graph api, v2.5?

I am trying to fetch the friend list using the code below
GraphRequest request = GraphRequest.newMyFriendsRequest(
token,
new GraphRequest.GraphJSONArrayCallback() {
#Override
public void onCompleted(JSONArray array, GraphResponse response) {
// Insert your code here
}
});
request.executeAsync();
}
The response returned after code execution is
{Response: responseCode: 200, graphObject: {"data":[],"summary":{"total_count":461}}, error: null}
Persmission to access friends and public profile is granted on login time.
How can i fetch my friend list and their public emails/ facebook emails?
You'll only receive the friends whcih are also using your app, see
https://developers.facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids
/me/friends returns the user's friends who are also using your app
In v2.0, the friends API endpoint returns the list of a person's friends who are also using your app. In v1.0, the response included all of a person's friends.
And, no, there is no workaround in case you wanted to ask.
You can recive your friends list using graph-api call
/* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/me/friends",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();
But the limitation is
api required access token with user_friends permission
only return friends who are also given access permission to the same app you are
using
.
https://developers.facebook.com/docs/graph-api/reference/v2.5/user/friends

How can we see users’ information through Facebook Graph API in Android?

I am making a dating app (android) by using Facebook API (You know the similar application that starts with tin…)
Anyways, I registered my application in Facebook developers and I also got approval to use functions that I need through 'Submit Items for Approval'(my Approved Items: email, public_profile, User_photo, User_like, user_work_history, user_education_history )
So, I can log in from my app using my Facebook ID and I can also see users’ basic information too.
But! The main problem is that I cannot see photos (except public_profile) even though I was approved for this.
So I really need someone’s help. Please help me!
It will be great if you can review the code I used (To use when looking at users’ photos)
new Request(Session.getActiveSession(), "/{user-id}/albums", null, HttpMethod.GET, new Request.Callback() {
#Override
public void onCompleted(Response response) { }
}).executeAsync();
Hey Use the following code. It works perfectly for me.
GraphRequest request = GraphRequest.newMeRequest(
accessToken,
new GraphRequest.GraphJSONObjectCallback() {
#Override
public void onCompleted(
JSONObject object,
GraphResponse response) {
// Application code
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "photos.limit(100)");
request.setParameters(parameters);
request.executeAsync();
Try the above code and you will get a jsonobject which can be used to get the image URLs. To know the response you get. Try Graph API explorer. The response format will be the same.
https://developers.facebook.com/tools/explorer
if you would like to get the photos of a user try the following code. Please note that you need the user-id to they photos
new Request(
session,
"/{user-id}/photos",
null,
HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
/* handle the result */
}
}
).executeAsync();
Please refer to https://developers.facebook.com/docs/graph-api/reference/user/photos/
You can use facebook graph api for accessing user info
GraphRequest request = GraphRequest.newMeRequest(
accessToken,
new GraphRequest.GraphJSONObjectCallback() {
#Override
public void onCompleted(
JSONObject object,
GraphResponse response) {
// Application code
}
});
To call this method, use below line,
request.executeAsync();
For additional info visit facebook official documentation
https://developers.facebook.com/docs/android/graph

how to get facebook friends list in android

i have user_friends permission when user authenticates and i tried a lot to get friends list from facebook
this is my call
/* make the API call */
new Request(
session,
"/me/taggable_friends" /*"/me/friendlists"*/ /*"/"+id+"/friends"*/ /*"/me/friends"*/,
null,
HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
/* handle the result */
Log.d(TAG, "friends list request response:" + response.getRawResponse());
}
}
).executeAsync();
i got friends list only with the account i have created the facebook id
if tried with another new account it just giving the count but NO DATA
can any one please help me
developers.facebook.com/docs/apps/changelog : "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"
Right now you can set Settings.setPlatformCompatibilityEnabled(true); and it will work but soon Fb will disable that.

how to get a list of all user friends (not only who use the app)?

in android application :
i want to get a list of all friends of the person who login to my app , not only those who use the app ?
i use the following :
private void makeMeRequest(final Session session) {
// Make an API call to get user data and define a
// new callback to handle the response.
RequestAsyncTask request =new Request( session,
"/me/friends",
null,
HttpMethod.GET,
new Request.Callback() {
#Override
public void onCompleted(Response response) {
// TODO Auto-generated method stub
Log.e(LOG_TAG,"Members: " + response.toString());
}
}).executeAsync();
}
but the response returns empty list , although there are some apps that show person's friend list ,what can i do ??
It is not possible to get ALL friends with v2.0+, only with Apps created before end of April 2014 by using v1.0 of the Graph API. And it will only work until end of April 2015. See changelog for more information about the versions: https://developers.facebook.com/docs/apps/changelog
There is also invitable_friends and taggable_friends though, but they are reserved for Apps on facebook.com:
https://developers.facebook.com/docs/graph-api/reference/v2.1/user/invitable_friends
https://developers.facebook.com/docs/graph-api/reference/v2.1/user/taggable_friends
This may also be interesting for inviting friends: https://developers.facebook.com/docs/games/requests/v2.1

Categories

Resources