Get Facebook fanpage status using Facebook app access token - facebook

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
;)

Related

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.

I can post links in a page feed but not just a message

I'm trying to post to a facebook page (as the page and as the admin user with each one access token) with just a parameter 'message'.
I've the same error in php and in Graph API Explorer in both cases:
{
"error": {
"message": "(#1) An unknown error occurred",
"type": "OAuthException",
"code": 1,
"error_data": {
"kError": 1455002
}
}
}
The same post to the API adding a paremeter link or just link without message works fine.
The user has granted those permissions: create_note, email, manage_pages, photo_upload, publish_actions, publish_stream, share_item, status_update, user_friends, video_upload.
The app is in Sandbox Mode and the user is a test user, not a real one.
I'm able to write to user feed and to create custom actions for him.
I've verified both, the page access token and the user access token with Access Token Debugger.
I've already reviewed a lot of questions in stackoverflow, tutorials and blog posts.
What am I missing?
UPDATED: I can't either post a link in page with app access token.

Facebook access token extending - "The access token does not belong to application xxx"

I went to https://developers.facebook.com/tools/explorer?method=GET, set up there ID of my Facebook page, set up there the correct permission for posting statuses on my FB timeline and generated access token.
Then I wanted to extend this short-live token on the long-term (60 days long valid token). So I did following - I put this URL to the browser:
https://graph.facebook.com/oauth/access_token?client_id=APP_ID_OF_MY_FB_APP&client_secret=SECRET_ID_OF_MY_APP&grant_type=fb_exchange_token&fb_exchange_token=GENERATED_ACCESS_TOKEN_FROM_THE_FIRST_STEP
and in the browser I saw this error message:
{
"error": {
"message": "The access token does not belong to application APP_ID_OF_MY_FB_APP",
"type": "OAuthException",
"code": 1
}
}
Which is weird, because the APP_ID of my Facebook app is correct, I've tried to post on the wall of the Facebook page and it was working.
But when I try to get extended access token, I am getting the error above.
What's wrong with the access?
Thank you
This almost certainly means what the error says, which is that GENERATED_ACCESS_TOKEN_FROM_THE_FIRST_STEP is not actually from the app ID that you're using in the APP_ID_OF_MY_FB_APP parameter
Check the access token you're trying to extend in Facebook's Debug Tooland ensure it was actually generated for your app
Your AppID param is not the same to the AppID in developers.facebook.com

facebook graph api error: An access token is required to request this resource

I wanted to publish a link on the given profile on Facebook via the app. Post to https://graph.facebook.com/PROFILE_ID/links with access_token and other necessary parameters.
For testing purpose, I got the access_token with Graph API Explorer and had the publish_stream and share_item extended permission.
Then I got the error
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException",
"code": 104
}
}
I tried fb_id and fb_username for the PROFILE_ID but got the same error. Anything wrong?
Thanks
Yes. /links is read only. To create a link, you need to POST to /USER_ID/feed.
https://developers.facebook.com/docs/reference/api/user/#links

Can get Facebook posts but not status message

I want to get a user status messages using the Facebook graph API. I have created an APP and with the help of APP ID/APP Secret code, I can get the access token and then get the posts by the user successfully with the following URL:
https://graph.facebook.com/USERID?fields=posts&access_token=XXX
But, I can not get the status message of the user. I am trying following:
https://graph.facebook.com/USERID/statuses?access_token=XXX
I get the following error:
{
"error": {
"message": "A user access token is required to request this resource.",
"type": "OAuthException",
"code": 102
}
}
How can I get the status message of the user? Thanks.
Read out the error message clearly:
It says you are not passing the access_token properly.
https://graph.facebook.com/**UserID**/statuses?access_token=**PASS_ACCESS_TOKEN_HERE**
I hope your token have 'user_status' and 'friend_status' permissions.
Hope it helps.