Get public facebook pages feed via graph api - facebook-graph-api

I want to get my hands dirty with code and start working on some small projects, so I decided to work on a facebook scraper that pulls feed from a public page and sends results via email.
when I try the URL : https://graph.facebook.com/page_id/posts?access_token=APP_TOKEN, I'm getting " This endpoint requires the 'manage_pages' permission or the 'Page Public Content Access' feature.
What am I missing?!
Thank you <3

In order to pull the feed with the Graph API, you need to:
Manage the Page, and use a Page Token of that Page to get the feed
or apply for Page Public Content Access, if you do not manage/own the Page

Related

How to get the page ID from a public notion page url without querying a database

I would like to be able to receive a public Notion page URL and return the ID of that page. I don't know if that is possible using the API.
I've tried taking the end of this URL and using it to retrieve the page in postman
https://www.notion.so/asnunes/Simple-Page-Text-4d64bbc0634d4758befa85c5a3a6c22f
https://api.notion.com/v1/pages/4d64bbc0634d4758befa85c5a3a6c22f
But it didn't work :/
The ID of the page is that alphanumeric string at the end of the URL before the query parameters. This would be what you would use when retrieving information from the page using the GET Page or GET block endpoints in the API.
If you do not have access to the page (i.e. your integration does not have access to the page in your workspace) you will not be able to use the API to make a request to it. You cannot use integrations to request information from other workspaces. Your integration is not authorized to access other workspaces.

How can I get posts from public pages with Graph API?

I have Graph API Facebook. As shown as when I get my Posts that work. but when I get public page that not wok and get error (#100) Pages Public Content Access requires either app secret proof or an app token. I generate token with all permissions but not work.
My posts(worked):
JasonStatham posts(not work):
You can do this via official GraphQL QPI, in specific the /page-post endpoint.
There is also a good example here of how to do that with Python.
However, you need to keep in mind that in order to use this API you need to have a Facebook Application with 'Page Public Content Access'.
To get that permission your app must be a verified Business app.

How to generate correct access token when my app already has Page Public Content Access

Our team is creating an app that analyzes Facebook reviews/recommendations. We have submitted an initial version of the app to FB for approval to use Page Public Content Access (PPCA), and have been approved. However when we started testing it after approval and after going to Live mode, we have not been able to generate any tokens that enable us to access the public content we are looking for.
There was a similar question posted recently, 54943575/facebook-graph-api-review-rating-data-with-page-public-content-access. However the answers that appeared for that one said that you can't access this content without manage_pages permission for each individual page, while the FB documentation clearly says you can do so with the Page Public Content Access: "Allows read-only access to public data on Pages for which you lack the manage_page login permission. Readable data includes business metadata, public comments, posts, and reviews." It is true that you need manage_pages in order to write, e.g. delete or post, content to any pages. The documentation also says that with PPCA permission, an allowed use is "Provide aggregated, anonymized public content for competitive analysis and benchmarking", for which clearly you would not be able to get manage_pages permission for all pages you access.
What this question boils down to is this" is the FB documentation for PPCA correct, and if so, how can we generate the access token(s) needed to use it, now that we have it?
Update: the following graph call (from the FB Graph API SDK for Python) that retrieves "posts" does work:
page_posts = graph.get_connections(id=getpage_id, connection_name='posts')
While the following one that attempts to retrieve reviews/ratings, does not:
page_reviews = graph.get_connections(id=getpage_id, connection_name='ratings')
The latter call produces the error:
(#210) A page access token is required to request this resource.",
"type": "OAuthException",
The Facebook Developers documentation says that the Page Public Content Access applies to ratings as well as posts, but this appears to contradict that, unless we are calling the graph incorrectly here.
You can only get a Page Token of Pages you manage - for other Pages (and Page Public Content Access), you can just use an App Access Token. More information: https://developers.facebook.com/docs/facebook-login/access-tokens/
For ratings/reviews, you MUST use a Page Token. Page Public Content Access only gives you access to the Page feed and photos, for example.

facebook graph api pages post message

I wanted to make a facebook API request that will post a message to page that I am admin of. Here i found out how can i do that but after trying it out in facebook graph api explorer with this scheme:
graph.facebook.com/page-id/feed
?message=Hello&access_token=your-access-token"
assuming I have a developer account linked to my page and publish_pages and manage_pages permissions are enabled and page-id and acces-token are replaced with my real ones. The problem is that I get a response of latest post on that website, the same as if I would write just graph.facebook.com/page-id/feed and there is no new post on my page.
I dont know if the recent facebook API update removed or modified that or if its just not possible.
trying it out in facebook graph api explorer with this scheme
graph.facebook.com/page-id/feed?message=Hello&access_token=your-access-token
You are making a GET request here - and GET is for reading data, not creating it.
Creating data requires a POST request. So you can either switch the request method from GET to POST via the dropdown there, and then click + Add parameter to add your parameters and values;
or you can add &method=post to the end of your GET request query string here - that is a way the API offers to explicitly overwrite the request method in environments, where you can only make GET requests.

Get comments of public facebook post

I'm trying to download every comment on a public facebook post (it's one of those "can you do this basic algebra problem" posts - I want to see what percent of the comments get it right).
The Graph API Reference shows that I should be able to just GET graph.facebook.com/v2.5/{object-id}/comments.
I believe the object-id of this post is {user-id}_{post-id}, where post-id is the id in the url. So given this url:
https://www.facebook.com/beth.mansfield.9/posts/10207885721596563
The user-id of facebook.com/beth.mansfield.9 is 1101752663 (from findmyfbid.com), and the post-id is 10207885721596563 (from the url), which makes the object-id="1101752663_10207885721596563".
When I try graph.facebook.com/v2.5/1101752663_10207885721596563/comments in the Graph API Explorer, though, I get:
{
"data": [
]
}
What am I doing wrong? Is there another way to get the comments? There are close to a million so loading them all in the browser and scraping with javascript would be unfeasible.
That is a user profile. You can only get data of a user profile if that specific user authorized your App. In that case, you would need to authorize with the user_posts permission. Just because it is public, does not mean you can get the data - that would only work for Pages.