How to remove FaceBook page tab via api - facebook

I've been banging my head over this for hours now... and can't seem to be able to remove a facebook page tab via api. The access token used has all of the following permissions "offline_access,publish_stream,manage_pages,publish_actions"
I've tried to make a call
https://graph.facebook.com/[page id]/tabs/app_[app_id]?method=delete&access_token=[access token]
the response is
{
"error": {
"message": "(#210) Subject must be a page.",
"type": "OAuthException",
"code": 210
}
}
if i use the the facebook graph explorer
http://developers.facebook.com/tools/explorer
the response is the tab object json... doesn't remove
if i do javascript api call
FB.api(**pageid/tabs/app_1234**, 'delete', {access_token: **My Access tocken**} ,function(response) {
alert(response);
});
the response is (#210) Subject must be a page.
I've read that if you include the full pagid/tabs/tabid then it becomes /paigeid/tabs/pagaid/tabs/tabid so i've tried
FB.api(**app_1234**, 'delete', {access_token: **My Access tocken**} ,function(response) {
alert(response);
});
the response is
(#803) Some of the aliases you requested do not exist: app_XXXXXXXXXXXX
if i use the C# facebook client
fc.Delete( "pageid/tabs/tabid")
the result is again
(#210) Subject must be a page.

The error message seems to be confusing. I have also come across this problem in past.
You are not using the correct access_token. Use access_token for page.

Related

Facebook Graph API | Page feed

I am having a problem with the facebook graph API, when I try to read a Page feed using graph../{pageId}/feed it works only for some pages. On other pages I get the following error:
{
"error": {
"message": "(#200) Requires extended permission: ads_management or manage_pages",
"type": "OAuthException",
"code": 200
}
}
The Page is restricted by location, as we found out in the comments. If it works for one user, most likely the other one is not allowed to view the page - which means that you can´t grab the feed with his User Token. The Page could also be unpublished, but i guess that´s not the case.
If you are unsure, try lifting the restriction and test it.
If that does not work, you should file a bug.

Facebook. Post to own facebook page as page

I want automatically post to my own facebook page as page not user after user creates article on my website.
First of all: it is possible to do that without user authorization?
I already tried:
FB.api(
"/page_id/feed",
"POST",
{
'access_token': pageAccessToken,
"message": "This is a test message"
},
function (response) {
console.log(response);
}
);
But got error that user not authorized.. Maybe there is way to work around and automatically post to my own facebook page?
In order to get this message
{
"error": {
"message": "(#200) The user hasn't authorized the application to perform this action",
"type": "OAuthException",
"code": 200
}
}
That would mean you didn't grant publish_actions permissions for the session user.
You need user authorisation at some point in the process then you extend the user token. See https://developers.facebook.com/docs/roadmap/completed-changes/offline-access-removal#extend_token
Once you have an extended token get the page token, and that token will have no expiry.
Ref: https://developers.facebook.com/docs/graph-api/reference/v2.2/page/feed
A page access token with publish_actions permission can be used to publish new posts on behalf of that page.

Get Facebook fanpage status using Facebook app access token

Is it possible to retrieve Facebook page statuses using an app access token?
According to the documentation I could use "any valid access_token or user access_token" but when I try to use the application access token I'm getting the following message: "A user access token is required to request this resource.". Am I generating the app access token in a wrong way? Is there anyway to access the statuses of a public Facebook fan page without a user?
It seems that a user access_token is required to query this connection.
Tried without any access_token in the Graph API Explorer on redbull page and the result was:
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException"
}
}
But after providing an app access_token:
{
"error": {
"message": "A user access token is required to request this resource.",
"type": "OAuthException"
}
}
This is a bit misleading!
Don't know if your still facing this issue. But here's a workaround :
By asking the graph API, you have this issue, but by using the FQL langage, it works perfectly with an App ID!
Here's an example for the 'PSG' page :
https://api.facebook.com/method/fql.query?query=SELECT post_id, type, attachment, message FROM stream WHERE source_id IN(SELECT page_id from page where username='PSG')&access_token=YOUR_APP_ACCESS_TOKEN
;)

Facebook: app access token is not recognized

I did quite a bit of homework before posting here but still could not find a solution for the following problem.
PROBLEM: when trying to access my facebook app's insights or subscriptions, it returns
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException"
}
}
I do everything according to the official documentation:
get app access_token by calling this api. It does return a token.
https:// graph.facebook.com/oauth/access_token?client_id=APP_ID&client_secret=APP_SECRET&grant_type=client_credentials
get insights/subscriptions by calling: https:// graph.facebook.com/APP_ID/subscriptions?access_token=TOKEN_FROM_STEP_1
but the last call returns the error message above.
Any ideas why?
After many trials and errors I found the solution.
Change facebook app type to 'Web' instead of 'Native'
Apparently facebook doesn't return subscriptions/insights for native apps

How to handle OAuthAccessTokenException in facebook api searches

I'm using Facebook API for searching. For example if I want to search for 'Conti' i get thsi url: https://graph.facebook.com/search?q=%22Conti%22&type=post
In this particular case, and others, instead of getting the list of results, I get this error:
{
"error": {
"type": "OAuthAccessTokenException",
"message": "An access token is required to request this resource."
}
}
why is this? should i get a token in order to the get the results?
UPDATE
Do I need to register an app?
You need to get the access token first, have a look at this tutorial:
Facebook Graph API — getting access tokens