Get Facebook Friend List with Name - android

I am using Facebook SDK 4.x, and i need to get friend list with name but i can't get it,
i have also implemented this graph API
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/me/friend",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();
and this is my reponse
response {Response: responseCode: 200, graphObject: {"summary":{"total_count":3},"data":[]}, error: null}
I am not getting friend list with name, if you have any idea than plz give me.
Thanks in Advance.

I got solutions for using this
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/me/taggable_friends",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
Log.e("getFriendsDat",""+ response);
}
}
).executeAsync();
You will get friend list with name and detail.
you have to add user_friends permission and need to submit your app for review.

First of all, it´s /me/friends, not /me/friend. That being said, you can only get access to friends who authorized your App too, with the user_friends permission. The response means that you have 3 friends, but none of them authorized your App with user_friends.
More information: Get ALL User Friends Using Facebook Graph API - Android

Related

How to get facebook friends list in android? [duplicate]

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 5 years ago.
Code:
AccessToken.getCurrentAccessToken(),
"/"+fbUserid+"/friendlists",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponseresponse) {
Log.e("friendsRes",response.toString());
}}).executeAsync();
{Response: responseCode: 200, graphObject: {"data":[]}, error: null}
In this code i am not able to get friends list in android, there is have any other code filter of facebook friends. Thanks!!
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/{friend-list-id}",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();
Note: A user access token with read_custom_friendlists permission is required.

get multiple pictures ID from page's post (Facebook GraphAPI - Android)

I am trying to get the posts from a page including all the pics related to the post.
I am able to get one picture from the post using object_id, but I need the other photos as well.
object_id returns only one Id which is the first photo's ID.
Please help.
GraphRequest greq =
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/{page-id}/posts",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
JSONArray data = null;
}
}
);
Bundle params = new Bundle();
params.putBoolean("redirect",false);
params.putString("fields", "object_id");
greq.setParameters(params);
greq.executeAsync();
The data should be in the attachments field. In the subattachments sub-field specifically.
You should test this in the Graph API Explorer to see the API response and update your Android implementation based on that.

Facebook SDK 4.5.0 returning wrong user id in android

In my App i am integrating facebook SDK 4.5.0.
To fetch details of user I am using method
GraphRequest request = GraphRequest.newMeRequest
In user json response i am getting wrong user id.
In case of IOS for same application and same user i get correct userId.
Can anyone help me to solve this?
This is my Code to fetch user details:
GraphRequest request = GraphRequest.newMeRequest(com.facebook.AccessToken.getCurrentAccessToken(), new GraphRequest.GraphJSONObjectCallback() {
#Override
public void onCompleted(JSONObject user, GraphResponse response) {
if (user != null) {
doLoginFb(user);
}
}
});
request.executeAsync();
After V2.0API user id is "app-scoped" so the id can be different for same user on different apps.
You can refer to the documentation here for more details.
It also says this :
No matter what version they originally used to sign up for your app,
the ID will remain the same for people who have already logged into
your app. This change is backwards-compatible for anyone who has
logged into your app at any point in the past.
If you're not mapping IDs across apps, then no code changes should be required.
Get some public profile of user:
Bundle params = new Bundle();
params.putString("fields", "id,name,email");
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/me",
params,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
try {
Log.e("JSON",response.toString());
JSONObject data = response.getJSONObject();
//data.getString("id"),
//data.getString("name"),
//data.getString("email")
} catch (Exception e){
e.printStackTrace();
}
}
}
).executeAsync();

Facebook Graph Api search in android

Just want to search all the events in a particular location by using new request in graph api,but error throws.
//Request for events
new Request(
session,
"/search?q=dubai&type=event",
null,
HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
System.out.println("Result: " + response.toString());
}
}
).executeAsync();
Permission:-
authButton.setPublishPermissions("publish_actions","manage_pages");
output:-
Result: {Response: responseCode: 400, graphObject: null, error: {HttpStatus: 400, errorCode: 100, errorType: GraphMethodException, errorMessage: Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api}, isFromCache:false}
suggest some way to solve it.
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/{event-id}",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();
Hope it will help you, for detail go through below link
https://developers.facebook.com/docs/graph-api/reference/event/
Try this new API, hope this help you.
Graph Event API
Graph API
for facebook Api, please refer below its developer link:
https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2
https://developers.facebook.com/docs/graph-api/reference
http://api-portal.anypoint.mulesoft.com/facebook/api/facebook-graph-api/docs/code
I hope it work.

Android Facebook SDK: How to retrieve Mutual friends Graph API response

I implemented this code from the Facebook SDK to get mutual friends.
Bundle params = new Bundle();
params.putString("fields", "context.fields(mutual_friends)");
// make the API call
new Request(
session,
"/{user-id}",
params,
HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
/* handle the result */
Log.d("results", response.toString());
}
}
).executeAsync();
How do i read the Response object and retrieve the total count and the list of mutual friends? I have successfully gotten the result in the log.
Thanks.
Booth people need autorize your friend_list_permission to you see the users in common. If not you need use all_mutual friends, but you just can run this in server, no working in clients. look documentation in all_mutual_friends.
I explain this post here.
https://stackoverflow.com/a/34663235/3516549

Categories

Resources