I am getting the following error when post to fb feed when using POST. It's working fine with GET method. Is there any permission needed to add.
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 manage_pages \\n and
publish_pages permission with page token; If posting to a page, \\n
requires both manage_pages and publish_pages as an admin with \\n
sufficient administrative permission, I20191112-19:45:36.182(5.5)?
type: OAuthException, I20191112-19:45:36.182(5.5)? code: 200,
I20191112-19:45:36.183(5.5)? fbtrace_id: AJbuFD_SHxv-s8iOWWyZIVg
}
graph.post("me/feed", wallPost, function(err, res) {
console.log(res); // { id: xxxxx}
});
Thanks
Publishing to a user profile is not possible anymore: https://developers.facebook.com/docs/graph-api/changelog/breaking-changes#login-4-24
You can only use Sharing Options, but there is no API for it with publish_actions being gone.
Related
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
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.
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'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.
I am trying to work out how to post to a Facebook page wall, when using my app as a different Facebook User (who is not the Page Administrator).
I get a range of error messages while testing:
Exception: 200: The user hasn't authorized the application to perform this action
The page administrator has visited the app and accepted the following permissions: publish_stream, manage_pages, offline_access
Here is the code I plan to use:
// Insert Page Administrators ID here
// This user is not the same user that is currently logged in and using the app
// This user is the page administrator who has authorised:
// - manage_pages
// - offline_access
// - publish_stream
$user_id = '123456789';
// Insert Page ID here
$page_id = '123456789';
$accounts = $facebook->api('/'.$user_id.'/accounts');
foreach($accounts['data'] as $account)
{
if($account['id'] == $page_id)
{
$page_access_token = $account['access_token'];
echo "<p>Page Access Token: $page_access_token</p>";
}
}
// publish to the wall on your page
try
{
$result = $facebook->api(array( "uid" => $page_id,
"method" => "stream.publish",
"access_token" => $page_access_token,
"message" => $message, ));
}
catch (FacebookApiException $e)
{
error_log('FB Error: Could not post on Page Wall. Page ID: ' . $page_id);
error_log('FB Error Message: ' . $e);
}
Note: There may be PHP errors in the code above, as I just spliced it on the fly, but its not so much the PHP errors I need correcting, but more my logically understanding of how I am meant to go about this process.
PROBLEM:
I can't access the $user_id/accounts information without an active user access token for the Page Administrator.
The end result that I'm trying to achieve is:
1.) A normal FB user goes to the app and submits a form
2.) The app posts a message on a FB Page wall, which is not owned by the FB user, but has previously been authorized by the Page Administrator with the following permissions manage_pages, publish_stream and offline_access
Q1. Since the Page Administrator has accepted the appropriate permissions, why can't I just generate an active user access token, without the actual Page Administrator user logging into the website?
Q2. Is there a way I can get the equivalent of /$user_id/accounts for the Page Administrator user_id, when logged into Facebook as a different user (which is why I do not use /me/accounts)?
Q3. Please confirm that my understanding of needing the page access token to post to the page wall is correct (or do I need the user access_token for the Page Administrator - see Q1)?
Q4. Anyone have a handy resource on what each type of access_token can actually access?
If you need any more information, please let me know.
I've spent the last few days working on this and I'm stuck.
Thanks!
You can ask the page admin for manage_pages along with offline_access. I do this in my production app to be able to post scheduled postings onto the pages' walls.
Nope. Not possible. That's what asking permissions is all about. And why not everyone gets to administer everyone else's pages. Could you image if you could administer anyone's page without them granting you access?!?
To post to the page as the page, you need a page access token. To post to page's wall as a user, you need a user access token.
Yes, please see: https://developers.facebook.com/docs/reference/api/permissions and https://developers.facebook.com/docs/authentication/
If you have further questions about any one of these, please start a new question. It's not really fair to users of stackoverflow to be hit with 4 questions in one and then to be asked followup questions to each of those.
I have done in Django:
Step to get Page_access_token:
facebook_page_id=360729583957969
graph = GraphAPI(request.facebook.user.oauth_token.token)
page_access_token=graph.get(facebook_page_id+'?fields=access_token')
This way you can get Page access token.
You can check this thing on Fb GraphAPIexplorer:
http://developers.facebook.com/tools/explorer
GET URL: fb_page_id?fields=access_token
for example: 360729583957969?fields=access_token
that will give you page_access_token