I am trying to delete an application tab from a facebook page.
According to the documentation, I should issue a DELETE request to "https://graph.facebook.com/PAGE_ID/tabs/app_ID" with a "manage_pages" access token, but when I do so I get the error "(#210) Subject must be a page."
I have requested the user for "manage_pages" permission and I have the correct access_token (GET Method works perfectly to show all the details).
The exact request is:
https://graph.facebook.com/270936169730418/tabs/app_533644953422033 (with an access token)
Does anyone know what am I doing wrong??
P.S I am using JS SDK and also trying to do this in the graph api explorer but results are the same.
The problem is with the access token. When using the Graph API Explorer (and checking "manage_pages") you might think that the access token showing at the top is a page access token. It is not.
You need to do GET /me/accounts
Then find the page you want and there is an access_token. Copy this and paste it into the Access Token input field at the top. Now do the DELETE [PAGE_ID]/apps_[APP_ID] and it will work.
Related
I want to generate a page access token with graph API 5.0 and don't know how to do.
I have an app, linked to a page which I am administrator, with all the permissions I need.
Everything works fine inside the graph API explorer.
The documentation says I need a user access token in order to get the page access token, using https://graph.facebook.com/v5.0/me/accounts?access_token=$user_access_token.
The problem is I don't know how to get it programmatically without having to confirm in the facebook popup. All I have now is the app access token, but this is an invalid parameter this endpoint.
Does somebody know where I'm wrong?
I create a demo application to request photos from facebook. I created an application token like this : 549933848476397|4a584ce5fda19cba2ed6630ed78ba8f4. But when use this request URL https://graph.facebook.com/1417833425116725/photos?access_token={app_id}|{app_secret}. It's does not work. Please help me. Actually When I use user token for this request, It's work ok.
If the Page is restricted somehow (age, location), you can only use a User or Page Access Token to get data like photos of the Page. The App Access Token got no relation to any User, so Facebook can´t detect if the User is even allowed to see the Page.
I am 100% sure the Page is restricted btw, you get an "Unsupported get request" error when trying to access the Page ID directly with the Graph API, and that usually happens when the Page is restricted.
Just try another Page with that exact same App Access Token, for example:
/bladauhu/photos
...works without any problem. Another sign that your Page is indeed restricted.
TL;DR: For this specific Page, you MUST use a User Token or Page Token.
I had an unknown permission exception when I tried to update/create/delete or doing anything my Page properties by using FB.api . I tried again by using Graph API Explore but it still gave me same error. I used google for 2 days but there wasn't any correct answer.
Below screenshot is my app Settings in the Adminster Page's account:
http://demos.kksolution.com/Facebook/screenshot/post-update-about-page.jpg
And here is the Graph API Expore screenshots:
demos.kksolution.com/Facebook/screenshot/list-pages.jpg
Next is the error:
demos.kksolution.com/Facebook/screenshot/post-update-about-page.jpg
Please help me. Thanks too much.
You need a page access token.
Page Access Token – These access tokens are similar to user access
tokens, except that they provide permission to APIs that read, write
or modify the data belonging to a Facebook Page. To obtain a page
access token you need to start by obtaining a user access token and
asking for the manage_pages permission. Once you have the user access
token you then get the page access token via the Graph API.
Doc: https://developers.facebook.com/docs/facebook-login/access-tokens/
Then use GET /me/accounts to get the access token associated to your page.
I am trying to get events from a Facebook page via Ajax.
But there should be no login process for user. For this reason I am trying to implement "Login as an App" by following the the documentation on this page.
I am getting the access token correctly by
https://graph.facebook.com/oauth/access_token?
client_id=YOUR_APP_ID
&client_secret=YOUR_APP_SECRET
&grant_type=client_credentials
However when I try to query Facebook Graph API with this access token I am getting an empty result set.
This is an example request;
https://graph.facebook.com/FAN_PAGE/events?access_token=ACCESS_TOKEN
I know the result set should not be empty because the same request with Graph Explorer returns the correct values.
Even a request like https://graph.facebook.com/FAN_PAGE/events?access_token=ACCESS_TOKEN_FROM_GRAPH_EXPLORER works correctly.
Any idea on whats going on? How can I get this to work correctly?
Actually the reason was not about the access token. The reason is that the page I want to get the events for is restricted. This works fine for unrestricted pages.
After a little research I found out that to read a restricted page's events (or posts etc.) you need a user access token. You get this by asking the user. (at login flow)
The other solution to get this data without prompting for a login is to get "page access token". You can generate a page access token by following this link.
And more on Access Tokens
I am trying to read the inbox and outbox of a Facebook Page. My first approach was to try to directly access the inbox of a page node. The URI below indicates how I tried to get it:
/{page-id}/inbox
Here is the error message:
You can only access the \"inbox\" connection for the current user.
Then I tried to access the conversations and threads edges as suggested in some places like so:
/{page-id}/conversations
/{page-id}/threads
Both URIs produce the following error:
(#298) You must be a developer of the application
I couldn't figure out what is wrong at all? There are some bug reports to Facebook, related to "#(298)", which were reported a few months ago but I can't believe it hasn't been fixed so far.
Any alternative approach is welcome.
This problem happens if you use a user access token instead of a page access token.
I was doing this in the Facebook Graph API Explorer and I thought I was using the page access token but I wasn't. When I ran {page-id}/conversations?access_token={page_access_token} from the API Explorer, it had the {user_access_token} in the Access Token field at the top. This was being sent in the actual request that the Explorer sent (as seen in Chrome's dev tools). I.e., the API Explorer was ignoring the {page_access_token} I entered and was using the value in the Access Token field.
Clearing the Access Token field or entering the {page_access_token} in that field resulted in the intended {page_access_token} being sent. Doing some of the steps in the browser vs the API Explorer showed me the way.
These are the steps to resolve the issue:
Get a user access token: with manage_pages and read_page_mailboxes permissions* by clicking Get Access Token from the API Explorer and selecting the specified permissions or visiting the URL below.
https://www.facebook.com/dialog/oauth?client_id={app-id}&redirect_uri={redirect-uri}&request_type=token&scope=manage_pages,read_page_mailboxes
Get a page access token: by running /me/accounts from the API Explorer or by vising the URL below.
https://graph.facebook.com/v2.0/me/accounts?method=GET&format=json&suppress_http_code=1&access_token={user-access-token}
Get conversations: Use the page access token (paste it in the Access Token field if using the API Explorer) from the above step to get conversations** by running /{page-id}/conversations or by vising the URL below.
https://graph.facebook.com/v2.0/{page-id}/conversations?method=GET&format=json&suppress_http_code=1&access_token={page-access-token}
* read_mailbox permission is not required, contrary to what I said in my comment above. Actually, the error message was incorrect, attempting to access Page edges with a user access token incorrectly gives user access errors instead of invalid Page access token errors.
** The user must be an admin of the Facebook Page to access its conversations.