Posting content as a user using graph api - facebook

I am trying to post content as a user using facebook graph api but I am not able to do so.
As per documentation,
link
Publishing
You can only publish to a Page and only with a Page access token of a Page if you can perform the CREATE task on the Page.
Also link
Updating
You can publish posts by using the /{user-id}/feed, /{page-id}/feed, /{event-id}/feed, or /{group-id}/feed edges.
According to above docs, I'm using POST v7.0/{user-id}/feed to post data with body as 'message=hello'.
But in response I get:
{
"error": {
"message": "(#200) If posting to a group, requires app being installed in the group, and \
either publish_to_groups permission with user token, or both pages_read_engagement \
and pages_manage_posts permission with page token; If posting to a page, \
requires both pages_read_engagement and pages_manage_posts as an admin with \
sufficient administrative permission",
"type": "OAuthException",
"code": 200,
"fbtrace_id": "AFMLDOB0UJOGejUhnOUSgtN"
}
}
So my question is, can I post only in a group or page and not as a individual user?
Thanks in advance for the help.

Posting to a user feed is not possible anymore, the required permission publich_actions has been removed a while ago.

Related

Facebook Graph API returns 200 status code when try to create a post for account

I created a Facebook account and I want to create a post with Facebook graph API by creating an http request from a C# server.
I created an app with Facebook developer:
I tried to create a post with Facebook's Graph API Explorer as explained in
https://developers.facebook.com/docs/pages/publishing/
I generated a token with pages_show_list and pages_read_engagement permissions. The app ID is the result GET request for "https://graph.facebook.com/v11.0" which returned an object with id property.
The POST request URL is: "https://graph.facebook.com/v11.0/{appId}/feed?message=hi&access_token={accessToken}"
I don't understand why I'm getting 200 status code and how can I fix it.
The error is:
(#200) If posting to a group, requires app being installed in the group, and \
either publish_to_groups permission with user token, or both pages_read_engagement \
and pages_manage_posts permission with page token; If posting to a page, \
requires both pages_read_engagement and pages_manage_posts as an admin with \
sufficient administrative permission",
As you can read in the docs, you need the following:
The pages_manage_posts permission
The pages_read_engagement permission
A Page access token requested by a person who is able to perform the CREATE_CONTENT task on the Page that is being queried
You are missing number one and number three, as far as I can see in your screenshot.
Btw, you can just use "/me/feed" instead, the ID is not neccessary as the Token includes it.

Facebook graph not give me access for content although I am a group administrator

My web-application need to fetch posts from facebook and save content in pages.
I'm have developer account with business access (authomatically contains permissions pages_read_engagement).
I'm try to get API-key by request: https://graph.facebook.com/v8.0/oauth/access_token?grant_type=client_credentials&client_id=****&client_secret=***
API return me access token and token type:
{
"access_token": "|", "token_type": "bearer" }
After that i try to get feeds via request: https://graph.facebook.com/APP_ID/feed?fields=is_published,id,attachments{title},message,created_time,full_picture&access_token=***&appsecret_proof=***
But API return me error:
"error": {
"message": "(#10) This endpoint requires the 'pages_read_user_content' permission or the 'Page Public Content Access' feature. Refer to https://developers.facebook.com/docs/apps/review/login-permissions#manage-pages and https://developers.facebook.com/docs/apps/review/feature#reference-PAGES_ACCESS for details.",
"type": "OAuthException",
"code": 10,
"fbtrace_id": "AbApv_PjRlplW2Abv61zNCx" } }
I'm trying to get a long-lived user access token, and it worked correctly, but only 60 days and blocked, Then I have to restore it manually.
Account with API is administrator of group and Page read content should work
Support replied that the rights pages_read_engagement will be enough, recommended to change the API version to 10.0, but it did not help. What am I doing wrong?
I tried to use the app key, but it does not work, you need to use the user access token (which has restrictions), or create a system user (which no longer has such restrictions)
I'm create the system user and use his API key.

Post on Facebook Page Using FB Graph API using FB Live but un-reviewed App

I want to post on my own Facebook Page using Graph API.
For this, I have created an App.
When App is in Dev Mode, I am able to post on page using Page Access Token with proper permissions.
However, the problem here is, the post are not visible to public unless I make the App Live. The posts are only visible to Page Admins.
But as I make my App Live, I am getting below exception from FB APIs.
{
"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": "abcdefgh"
}
}
I regenerated the Page Access token after I make my App Live but still above error is coming.
I checked some resources which says that I need to submit my App for review. But I don't want to go through that lengthy process.
So, Is there any otherway with which I can post on facebook page using API without putting my App for review process ? Will any other kind of token (i.e. other than page access token) work here ?
Please note, I want to make sure the posts I make to be visible by everyone and not just page admins.

Get post likes without read_stream permission

I'm trying to achieve the following:
User logs in on my website using a custom Facebook Login
User creates a post on his wall using the feed dialog from my website
I store the post_id in a database
I need to query the post in order to get the number of likes it got with FB API
The problem is that Facebook new application review won't authorize my application to use the read_stream permission since it's in a website (as their policy says)
It seems (as on documentation) that I can retrieve a single post (published as "public") with just a valid user access token; but the Open Graph Explorer tool responds with this:
{
"error": {
"message": "Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100
}
}
Is there a way I can query a single public post with just a valid access token and without read_stream permission?
Or is there a way I can use the read_stream permission on a website?
Thank you in advance for your help!

Accessing an application page with facebook graph api

I'm trying to access a facebook page's conversations using the graph api.
Accessing the page itself (with /{page_id}) is fine, but I get on oauth exception for the conversations.
My request in the graph explorer is this one :
/{page_id}/conversations where {page_id} is, well, the page id :)
and the error is
{
"error": {
"message": "(#10) Application does not have permission for this action",
"type": "OAuthException",
"code": 10
}
}
According to the documentation, the required authorization is read_page_mailboxes, which I granted. Here are the rights of my token as shown in the oauth debugger :
public_profile, basic_info, read_page_mailboxes, manage_pages, user_friends
Are there other permissions I'm supposed to require ?
In fact, just asking for the permission itself is not the right way to access to this page informations.
You have to recover the page access token located at /{page_id}?fields=access_token and use this token in order to access the conversations.