I've created a dummy page and I'm trying to browse
https://graph.facebook.com/me/accounts?access_token=MY_AUTH_TOKEN
but all I get is an empty answer.
Read the documentation here on facebook and authentication : http://developers.facebook.com/docs/authentication/
Related
I am hitting a wall while developing seamless integration of a Facebook page with my bot.
Essentially I want to achieve same integration than Chatfuel or Manychat have, where being logged in with your Facebook account lets you to just choose what page you are connecting to them and you are good to go.
The problem I am facing is generating the proper token in order to bind the selected page to my app (bot). As per Facebook documentation:
When you create a subscribed_apps edge, the page-id you use in endpoint must match the page ID of the page access token used in the API call. The app that the access token is for is installed for the page.
Given the call has no other parameter than the access token, this access token has to be enough for Facebook to:
Authorize the action on the page.
Identify what app is being subscribed to the page.
This is confirmed while using the Facebook Graph API Explorer, where one selects the page and the app to bind and a proper access token is generated:
This token properly works using cURL in the terminal:
$ curl -X POST 'https://graph.facebook.com/v3.0/<MY_APP_ID_HERE>/subscribed_apps?access_token=<TOKEN_PASTED_FROM_GRAPH_API_EXPLORER>'
{"success":true}
With the Facebook Access token debugger (info icon on the left of the access token, then open in Access token tool), it is confirmed that the token knows about both the page and the app that have to be connected.
The question is, how are these page-app related token programmatically produced? I can't seem to find the proper API call in Facebook documentation and it is by all means possible, as Chatfuel and Manychat are doing this.
Thanks in advance for your support Lars Schwarz and community!
Adding some detail to Alex's answer, for it to be more complete.
When subscribing an app to a page, Facebook needs to:
Know what app you are talking about.
Know what page you are talking about.
Know that you have permissions on that page to subscribe an app.
How does Facebook know it all?
1 comes from the fact that Facebook login happens in the context of a page, actually, the Javascript code for Facebook contains your appId:
js.src = 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v3.0&appId=<YOUR_APP_ID_IS_HERE>&autoLogAppEvents=1';
2 Comes from the page_id in the URL used to subscribe apps to pages:
https://graph.facebook.com/v3.0/YOUR_APP_ID_HERE/subscribed_apps?access_token=YOUR_ACCESS_TOKEN_HERE
3 Comes from the access token, obtained in the context of an APP through Facebook login, that is passed as parameter in the URL used to subscribe apps to pages:
https://graph.facebook.com/v3.0/YOUR_APP_ID_HERE/subscribed_apps?access_token=YOUR_ACCESS_TOKEN_HERE
To do this, you need to put FB Login on your site/customer portal and request pages_messaging and manage_pages permissions. The person that logs in must be a Page Admin.
Once your app has been granted that permission for the page, you can generate a page access token as described here:
https://developers.facebook.com/docs/pages/access-tokens
I am trying to get my Meteor app to save user_birthday and email in MongoDB. All I am asking for is an example for a URL that queries Facebook Graph for user_birthday and email by providing a facebook user ID and the corresponding access token. The perfect answer would be a link were I just copy my user ID and access token and it gives me my email and my birthday.
Thanks in advance :)
This would be the API call: /me?fields=email,birthday&access_token=[your-user-token]
https://graph.facebook.com/me?fields=email,birthday&access_token=[your-user-token]
I'm having problems with the facebook graph api, I have an iframe app that return all the albums from and specific fanpage, but from the past 3 days it stops working, I figured out that I was because the API returns me false, here is the URL:
http://graph.facebook.com/347077778656045
and here is the fanpage URL:
https://www.facebook.com/pages/Muebles-HRP/347077778656045
my facebook id is 347077778656045, and if I use another fanpage id the app works as it should.
I think false being returned means that the authenticated user's access_token doesn't have permission to view that object. Similar post: Graph API for user returns false even with a valid user access token
I am not able to access that page.
Have you unpublished page? If so only admins can see that page
FYI : FAQ
I'm building a webpage Facebook app, I need the app to access a Facebook page and access and display user posts from the page. I have admin control of the Facebook page.
How should I go about achieving this: If I add my Facebook app webpage as a App on my Facebook page will it be able to access the information on the Facebook page?
You will have to grant your application the "manage_pages" permission :
https://www.facebook.com/dialog/oauth? client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&scope=manage_pages&response_type=token
once you have that permission you can make a request for an access token :
https://graph.facebook.com/oauth/access_token?
client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&
grant_type=client_credentials
With this access token you can make requests to the graph api as your page...
You can read more here on the authentication documentation. Look for "App login" and "Page login"
I am following the Facebook developer documentation for making a post to a Facebook 'Page' as the Page itself, which according to the docs requires impersonation. I've gotten the access token for the page itself, as well as the Page's ID, by making a call to the "accounts" feed for the user who's the admin for the Page. I then POST to
https://graph.facebook.com/[Page_ID]/feed
With the post items
access_token
and
message
containing the access token and the message, and I get a JSON string back with a post ID. Which all seems to indicate that it is posting the message to the page. HOWEVER, when I go to the particular Page, it doesn't display the posted status.
Does anyone perhaps have any idea why that might be?
Thanks in advance everyone!
Did you make sure to get the "publish_stream" permission from the user?
http://developers.facebook.com/docs/authentication/permissions