Facebook. Post to own facebook page as page - facebook

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.

Related

What is the permission scope of publishing a post users wall in Facebook Graph API?

I published a post to page successfully by using Facebook Grap API over postman tool.
There are informations below for publish post in a page:
Post Request: {{url}}/{{pageId}}/feed?access_token={{page_access_token}}&message=This is a test
Scope: pages_manage_posts,pages_read_engagement,pages_read_user_content,pages_show_list
But I want to publish a post to user's own timeline (other says user's wall).
I explore this link https://developers.facebook.com/docs/graph-api/reference/post#Creating
They wrote this: You can publish posts by using the /{user-id}/feed, /{page-id}/feed, /{event-id}/feed, or /{group-id}/feed edges.
Then I used below informations for a publishing a post on user's wall.
Post Request: {{url}}/{{userId}}/feed?access_token={{user_access_token}}&message=This is a test
Scope: pages_manage_posts,pages_read_engagement,pages_read_user_content,pages_show_list
After trying it didn't work. Response is:
{
"error": {
"message": "(#200) If posting to a group, requires app being installed in the group, and \\\n either publish_to_groups permission with user token, or both pages_read_engagement \\\n and pages_manage_posts permission with page token; If posting to a page, \\\n requires both pages_read_engagement and pages_manage_posts as an admin with \\\n sufficient administrative permission",
"type": "OAuthException",
"code": 200,
"fbtrace_id": "*****"
}
}
{{url}} are tried as https://graph.facebook.com and https://graph.facebook.com/v14.07
Which scopes, url and path should I use?
How can I achieve this?
Thank you

Getting 200 permission error while creating business manager account through facebook sdk

I have created a facebook app which has following permissions.
business_management
ads_management
manage_pages
ads_read
I am creating business manager account using user token which has permission but I am getting 200 permission error. I am using the following API call
FB.api(
'/10208598...40975/businesses',
'POST',
{
"name":"manager account",
"vertical":"ECOMMERCE",
"primary_page":"678031702295134",
"timezone_id":"1"
},
function(response) {
// Insert your code here
});
but i am getting this response
{
message: "(#200) Permissions error",
type: "OAuthException",
code: 200,
fbtrace_id: "CVL2mV+oi6K"
}
please tell me what I am doing wrong.
thanks.
From my experience, you are most likely not scoped to that business. Try verifying that you are properly added to the business account, and that you have the appropriate permissions to create.
you can do that either in the web ui or by calling the 'graph_url/api_version/business_id/assigned_users?access_token=' to verify.

Problems with facebook api posting to company page using application id: (#200) The user hasn't authorized the application to perform this action

I am stuck with access rights in trying to post on facebook company page.
I have created an application and gotten appId and secret.
I have linked the application to the existing facebook page.
I have retrieved an accessToken for the appId.
But get the response: "(#200) The user hasn't authorized the application to perform this action."
Which user does the error statement refer to? the AppId user? The administrators of the page (me)? And where can I grant these missing rights?
I am trying to achieve that the post functionality is not facebook-user-dependent, but is company (or appID) dependent.
I am really confused about this...
Off course we could create a bogus user (kept in the company files) and post as this user - but that goes against the Facebook policy, and that is not the road we want to go down...
function FB_doPost(link, message, accessToken) {
console.info('doPost');
FB.api('/pageid/feed', 'post', {
access_token: accessToken,
message: message,
link: link
}, function (response) { if (!response || response.error) { console.info('error occured: ' + response.error.message) } else { console.info(' post id: ' + response.id) }; }
);}
In order to post to a Page "as Page", you need to do the following:
Authorize a Page Admin with publish_pages and manage_pages
Use the /me/accounts endpoint to get a Page Token for that Page
Use that Page Token with the /pageid/feed endpoint to post as Page
Make sure you know about the difference between Access Tokens, here are some links about that:
https://developers.facebook.com/docs/facebook-login/access-tokens
http://www.devils-heaven.com/facebook-access-tokens/

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.

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