Facebook sdk /me/friends/ return empty data - facebook

I'm trying to get the names and ids of friends using my application, but the data is empty.
{
"data": [
],
"summary": {
"total_count": 1
}
}
I'm requesting the user_friends permission and it is included.
My all test Users include user_friends permission.
permmissions granted to my app
But I cannot get friends list.
Can someone help?

Related

Facebook friends returning empty data

I implemented possibility to search friends from facebook who logged into my app using facebook.
It was working, I was getting one facebook id as I supposed, but now I trying to work about functionalities around this and I am getting empty data. I even check with other friend but still data for friends is empty. Something changed in last month?
{
"id": "49....38",
"name": "Karol Wiśniewski",
"friends": {
"data": [
],
"summary": {
"total_count": 359
}
}
}
EDIT: Yes, I have people who logged in using facebook to my app in friends

Getting empty friends list

My goal is to get a list of user facebook friends using Facebook Graph API. At least those, who have used social authentication on my website
I have read, that after v2.0 I can get only a list of friends, if the following conditions are met:
A user access token with user_friends permission is required to view
the current person's friends.
This will only return any friends who have used (via Facebook Login) the app making the request.
If a friend of the person declines the user_friends permission, that friend will not show up in the friend list for this person.
When I get a token and check
/v2.5/me/permissions
Result:
{
"data": [
{
"permission": "user_friends",
"status": "granted"
},
{
"permission": "public_profile",
"status": "granted"
}
]
}
I am testing 2 user accounts, who are friends. I have used both for login in my web application using Facebook Login.
But when I do
v2.5/me/friends
Result:
{
"data": [
],
"summary": {
"total_count": 1
}
}
What is the reason of empty friends set?
Make sure all those friends authorized your App with user_friends too. If they only authorized without user_friends, they will not show up. The response looks like it worked correctly.
Sidenote: It is not allowed to have 2 user accounts on Facebook, you can only have one account - with your real name.

How to get a number of friends that like particular page in Facebook [duplicate]

This question already has answers here:
Facebook API: Get fans of / people who like a page
(8 answers)
Closed 8 years ago.
I would like to build an app that tells user how many of his friends like a particular facebook page.
Let's say the name of page is Machester United. And I have 20 friends who like that page.
How can I do that? Should I use facebook graphAPI? Are there any other ways>
I am very new to this. Can you give me some key concepts/things that I should look into?
I think the Social Context API might be the right thing for you, if you're mainly interested in the number of friends which like a certain Facebook Page.
See https://developers.facebook.com/docs/facebook-login/social-context/v2.0
Use
GET /cocacola?fields=context.fields(friends_who_like)
to see which/how many of your friends like the CocaCola Page.
The result will look like
{
"context": {
"friends_who_like": {
"data": [
{
"id": "123456789",
"name": "Firstname Lastname"
}
],
"paging": {
"cursors": {
"before": "ODQ5MDkwMjQ2",
"after": "ODQ5MDkwMjQ2"
}
},
"summary": {
"social_sentence": "4 of your friends like this.",
"total_count": 4
}
}
},
"id": "40796308305"
}
The context.summary.total_count field will contain the number of friends which like the Page.
Try it here: https://developers.facebook.com/tools/explorer?method=GET&path=cocacola%3Ffields%3Dcontext.fields(friends_who_like)&version=v2.0
Keep in mind that
In order for a person to be identifiably returned in a context edge, they must have:
Logged into the app.
Granted the user_friends permission.
Granted the appropriate content permission in order to see the action. For example, to appear in the friends_who_like context edge, each friend has to have granted the app the user_likes permission.

Not getting albums of some users in facebook sdk graph api

I am querying in graph api like this /userid/albums
I am getting response of most users successful but I am though not getting response of some users. It give me blank response-
{
"data": [ ]
}
You need to ask the user for user_photos/friends_photos in order to get the albums of the concerned user or his friends.

check publish_action permission using javascript

How can I check if the user has given permission and not disabled (publish_action) permission
to do post (publish_action) using open graph apis ?
Make a call to /me/permissions with the user's access token or /USER_ID/permissions with the app access token. It shows which permissions you have for that user.
Sample output is:
{
"data": [
{
"installed": 1,
"manage_pages": 1,
"user_actions.music": 1
}
]
}