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.
Related
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?
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
I have an application that uses Facebook login module.
I tried to get manage_page and publish_page permissions but Facebook is not giving these permission without review. So, I tried to create test user and gave him above permissions.
Then logged into Facebook with test user. Facebook is not letting test user to create facebook page.
I need to access user's pages but cannot do because I cannot create at the first place.
I got the access_token of the test user and called facebook api with following json. And then I can see my test user had created page when I login to facebook.
/me/accounts
{
"name": "Your Page Name",
"category": 2211,
"about": "Description",
"picture": "your_page_picture_url",
"cover_photo": {
"url": "your_page_cover_photo_url"
},
"classic": 0,
"city_id": 2505639
}
My applicaton uses this endpoint to retrieve a list of pages to which a user has access.
For my personal account, which is the admin of a page, it works fine:
https://graph.facebook.com/me/accounts?access_token=[accesstoken_for_my_personal_profile]
Results:
{
"data": [
{
"access_token": "<the access token>",
"category": "Record Label",
"name": "Page Name",
"id": "Page ID",
"perms": [
"ADMINISTER",
"EDIT_PROFILE",
"CREATE_CONTENT",
"MODERATE_CONTENT",
"CREATE_ADS",
"BASIC_ADMIN"
]
}
]
}
But when we create a totally new facebook profile (regular user, as per my personal one) - and get it verified using mobile phone / SMS based verification, it only ever returns blank here, despite being given page admin access to the same page and having requested an access token exactly the same way:
https://graph.facebook.com/me/accounts?access_token=[accesstoken_for_newly_created_profile]
{
"data": [
]
}
UPDATE
The access token permissions are also different.
So when calling https://graph.facebook.com/me/permissions?access_token=xxx, the bad user only has public_profile and installed as 'granted' - but the good user has all the requested permissions including 'manage_pages'.
The URL used to request the tokens in the first place is here:
https://www.facebook.com/dialog/oauth?client_id=[my_app_id]&redirect_uri=https://www.facebook.com/connect/login_success.html&scope=manage_pages,read_mailbox,read_stream,publish_actions,user_likes&response_type=token
This directs to a login page which logs in as the user for which we want a token.
Courtesy of #CBroe above:
The issue here was that since API v2.0 came in, requesting access tokens for users who do not have a role in the requesting app will not assign certain permissions (in our case 'manage_pages') unless the app has been reviewed.
I'm writing a facebook web app with Graph API for publishing on a page wall automatically. I'm the page administrator and I've set up the app permissions for requiring manage_pages, offline_access, read_stream and publish_stream. My app will be like twitterfeed app with something different (I've no rss feed as a source).
For the first step I call:
https://graph.facebook.com/oauth/access_token?client_id=".$app_id."&client_secret=".$app_secret."&grant_type=client_credentials
When this call return an access_token I call:
https://graph.facebook.com/100344706779072?fields=access_token&access_token=". $access_token
Here I have problems: as facebook doc says (https://developers.facebook.com/docs/reference/api/page/#page_access_tokens) I must get page_access_token in this way, but this call return only the page id..
So what I'm doing wrong?
From the facebook docs here: https://developers.facebook.com/docs/howtos/login/login-as-page/
you need to use the access token you got in the first call and make a second call to https://graph.facebook.com/me/accounts?access_token=$access_token
and you'll get a reply that looks like this:
{
"data": [
{
"name": "PAGE_TITLE",
"access_token": "PAGE_ACCESS_TOKEN",
"category": "PAGE_CATEGORY",
"id": "PAGE_ID"
},
{
"name": "PAGE_TITLE",
"access_token": "PAGE_ACCESS_TOKEN",
"category": "PAGE_CATEGORY",
"id": "PAGE_ID"
},
...
]
}