How to get the user's list of accounts in Facebook API? - facebook

Good day, the app can't get access to the user's list of accounts. "me/accounts" returns an empty array.
I have checked this by creating a test application in the user's account and opening access to "pages_show_list". I executed it in Graph API Explorer and got the list. However, through another application, I can't access the list of accounts, even though it has Advanced access for pages_show_list.
When logging in through Facebook, I request "pages_show_list, instagram_basic, instagram_manage_messages, pages_manage_metadata, pages_read_engagement, public_profile". I have Advanced access to these permissions in my app.
When opening the Facebook login, it only requests the name and profile photo. Do I need to get any other permissions?

Related

Facebook Graph API - access without logging in multiple times

I am making a system where users can log in a see stats of Facebook pages I administer.
I don't want the users to have to log in each time they visit the site, and more importantly they will only be able to see the stats for all pages if it was my account that was logged in.
Is it common practise to log in with my account, get an extended access token and store in a database so future users don't need to keep logging in via Facebook to see the stats?
You could make use of the "manage_pages" extended permission. If your application received this permission via an User Access Token, it could call
/me/accounts
with this Access Token and receive the Page Access Tokens for all Pages this User administers. With these you could access the Page insights of the respective Page.

Using FQL to retrieve facebook status's of all users who are using My Facebook Application

I would like to retrieve status's of all users who are using my Facebook application.
I am not interested in retrieving the user's friends statuses only interested in retrieving the users who are using my Facebook application and have granted my application the "read_stream" permission.
I can successfully retrieve status's of the logged in user or one of the logged in user's friends by calling:
SELECT post_id, message, attachment, type FROM stream WHERE source_id = "SOME ID" AND type IN (46, 247)
But that is not my goal. I would like to get "All" users who are using my Facebook application and get their latest status feed without any particular user being logged in.
For example: I am not logged in facebook now neither or you. But when you click the link below you will get an RSS Feed of this particular user. This user is actually a business page so it is open to the public. Click This Link
I would like to retrieve this information from users who allow my application "read stream" permissions.
I cannot retrieve this information on personal Facebook user pages. So I am under the impression I need to build a Facebook Application to do so.
There is no way to retrieve a list of the user IDs of your app's users, and if you already have the user IDs you already have the correct query format - you just use the access token from the users to make that call
The fact you can't retrieve a list is covered here: Facebook. How to get list of all users of my app?
If you need the status updates of all your users, you should probably be using the Realtime Updates API to get a notification sent to your app when the user adds a new message, you can then use a cached [and still valid] access token for that user to retrieve the new messages

How do I grant my app permissions on pages or groups I created?

I have an app, and I can write to user's walls with it, having requested the publish_stream permission when they sign in.
I've also created a page and a group, and would like my app to be able to write to those. (Specifically, I want my back-end server to post some updates to those periodically, without a user being involved.) The ability to do this seems to be implied by the descriptions of the /feed parts of those here https://developers.facebook.com/docs/reference/api/page/ and here https://developers.facebook.com/docs/reference/api/group/ . However, I can't seem to find a way to authorize the app to write to these pages. Those docs say it can be done if you have publish_streams and manage_pages. OK, but how do I grant those to my app?
In the user case, you request those permissions when the user signs in via the OAuth flow. However, the page and the group never sign-in, so there's no way for them to grant the app permission. I looked around the settings pages for the group and the page, and couldn't find anything that will let me add the app. So how do I give the app the required permissions to post to the group and the page?
Found it!
http://developers.facebook.com/docs/reference/api/application/
http://developers.facebook.com/docs/howtos/login/login-as-page/
"Application Page Access Tokens
To perform the following operations as an Application Page, and not the current user, you must use the Application's Page access token, not the user access token commonly used for modifying Graph API objects nor the Application access token. This access token can be retrieved by issuing an HTTP GET to /USER_ID/accounts with the manage_pages permission. This will return a list of Pages (including Application profile pages) to which the user has administrative access, along with an access_token for each Page.
Note: Applications that are configured as Native/Desktop apps will not be able to make API calls that require an application access_token."
So:
I went to http://developers.facebook.com/tools/explorer/ and, as me, created an access token with "manage_pages" permission.
I then went to https://graph.facebook.com/$myname/accounts?access_token=$accesstoken
and it gave me a list pages and apps that I had given permission to. I copied the access_token from the relevant page, and pasted that into my code, so that the server-side create event code always used that access token.
And it worked!

Facebook Graph Api access Alcohol Related Page

I am looking for a solution to fetch the feeds of an alcohol-related/age-restricted Facebook Brand Page by a website or back-end service to show these infos in that website for any user.
i.e: https://graph.facebook.com/JimBeam
The standard call results with an error or false.
I know the reason is the age-restictrion because of the relation to alcohol.
If I am connected to Facebook and add an access_token (user-token or page-token) to the request, I get everything I need, but it doesn't work if I am not connected.
If I request the page-token with offline_access, it also does not work when I am not connected to Facebook.
I am a bit confused with all this token types, offline_access, permissions and so on.
Is possible to get the fb-graph-feed of an age-restricted page and load that into a website?
To get an age-restricted feed you need to have a user access token that meets the criteria for the page. So if a user is visiting your site, they will need to authenticate your app, and then you can use the resulting access token to pull information to your website from that restricted page.
You should not be using a user's access token to display content to another user who does not meet the restrictions on the Facebook page.
An added problem is that Facebook does not expose a page's restrictions via the API, so you can't tell if a user has permission to see the page until your API request returns no data.

How can I get a user access token for a specific facebook test user?

According to Facebook Devlopers: Test Users, I can list the test users of my facebook app by making a request to https://graph.facebook.com/APP_ID/accounts/test-users?access_token=APP_ACCESS_TOKEN. The response includes a valid user access token for each user.
How can I get a valid user access token for a specific test user without downloading the whole list of test users?
Test users should be able to be authenticated with your application in the same way as an other user. So use the Authentication flows while logged in for a specific test user.
Other than that there is no way to call one by one without parsing with code.