Create an app to get public data from facebook - facebook

I want to create an application that gets public information from different users or pages but using the same app access token. Is that possible or is the app access token limited to getting data from the user registering the application? Note that this is without a human user logging in first.

Related

Getting Public Facebook Posts with an App Token

I'm using the facebook graph api to access publicly posted information of an arbitrary user. I'm using my own profile for testing and have posted a single public post.
The endpoint that I'm using is:
https:graph.facebook.com/v2.4/{id}/feed
However, this endpoint returns an empty set of data:
{
"data": [
]
}
This occurs regardless of which type of access token I use. I've tried an app access token, a regular access token with no additional permissions, and a regular access token with 'user_posts' selected. I'm especially confused about receiving no data with the last access token as that should include all posts that I've made.
I'd much prefer to use an app access token if possible - it's much easier to get a new one than it is to prompt a user to allow access. What am I doing wrong here?
This can't be done for all users. Facebook requires a person to be logged in order to see public posts from certain users. App credentials won't work to see an arbitrary user's public posts.

Retrieve Public Facebook Posts with App ID and App Secret

I have a Facebook app that is associated with a companys page. The page has public posts on it and I would like to retrieve those posts (and eventually images etc) via the spring-social-facebook plugin for spring-boot.
I am able to retrieve the Page object without authenticating as a specific FB user, but how can I get the public information (such as the wall posts, images uploaded etc) associated with the company?
Page page = facebook.pageOperations().getPage("1234567");
List<Post> posts = facebook.feedOperations().getFeed();
model.addAttribute("page", page);
model.addAttribute("posts", posts);
return "hello";
I am able to access the page object (${page.category}), but when I try to get their posts I get the following exception:
org.springframework.social.MissingAuthorizationException: Authorization is required for the operation, but the API binding was created without authorization.
My goal is to create REST services for this specific company to use to populate a read-only front end with its own public FB data without requiring any end user authentication with Facebook.
Thank you!
According to the Page Documentation, to fetch the posts-
An app or user access token is needed to view fields from fully public pages.
A user access token is needed to view fields from restricted pages that this person is able to view (such as those restrict to certain demographics like location or age, or those only viewable by Page admins).
A page access token can also be used to view those restricted fields.
To get the posts from a public page without user authentication, you can use the app access token(app_id|app_secret) (expires never).
But please note its not safe to expose the app access token to the client side because it is kind of a password to your app.

Is it possible to view/download the content of the POST done via my facebook application?

I have a scenario, where an authorised user through my application is posting status/uploading pictures via my application by granting required permissions. My application uses graph APIs.
Now, as app administrator if I want to see the content of the post, that the user has uploaded via my application. How do i do it?
I know in graph APIs, I have INSIGHTS api. But, it just gives us the statistics of the posts done via my app or user.
Can i really see the posts?
Assuming as an app admin I only have app access token and app ID. I dont store user access tokens with me.
Actually, I worked on the problem with every possible way. Found out that, even being an APP administrator I will need user access token (stored with me), without which these data shall not be retrieved via APIs.
My need was not to use user access token; But, no Its not possible via APIs as of now.

Facebook app using access tokens for multiple users behind the scenes

I am building a Facebook application whose purpose is to gather statistics about Facebook users by querying their profile pages every so often. There is a sign up process where a user consents to the application and is redirected to Facebook to authorize the app. After the app has received the user's permission, it stores the access token with the user's Facebook ID number.
Every so often I want to be able to run a script that loops through all the access tokens in my database and queries the corresponding user's profile page. I am using Facebook's PHP SDK for development and therefore receive long-lived access tokens.
However, I am running into the issue of the 60 day expiration of the access token. I don't know how I can renew these access tokens, since the user does not initiate API calls; my own script does and therefore it has no information about the user being logged in or not when trying to run an API call. Is there any way to renew these access tokens behind the scenes without any information about the user whom I'm trying to query?

Access "Public" Graph API resources from an app?

I am creating a web application that is trying to use "public" Facebook content.
It is not your traditional "Facebook Application" because I'm not actually signing up Facebook users to use it, but the users will be all server-side.
I've come to a point in which I am having to use an "access_token" for certain "public" pieces of content and I have been able to generate a app access_token but this does not work for the public data I'm interested in accessing.
access_token's created via
https://graph.facebook.com/oauth/access_token?client_id=APP_ID&client_secret=APP_SECRET&grant_type=client_credentials
do not work for
https://graph.facebook.com/chickfila/notes?access_token=CODE_FROM_ABOVE
which is publicly accessable w/o login here...
http://www.facebook.com/ChickfilA?sk=notes
Any way to give an app itself a user-level access_token?
I had a very similar problem with publicly available event data. What I had to do was to create an offline access token for the admin of the application.
So, log in with your admin and open the following URL (replace APP ID with your ID and eventually you need more permissions, but read_stream and offline_access should do the trick):
https://graph.facebook.com/oauth/authorize?client_id=APPID&scope=offline_access,read_stream&redirect_uri=http://www.facebook.com/connect/login_success.html
This will give you a code, that you will paste in the following URL (with your APP ID and SECRET):
https://graph.facebook.com/oauth/access_token?client_id=APPID&redirect_uri=http://www.facebook.com/connect/login_success.html&client_secret=SECRET&code=CODE
This will give you an access token that should work forever (or until you change your password).
Recently I used the access token freely available from the Facebook Graph Explorer which will let you browse different graph resources and will let you specify what permissions you need. For this you can tell it you want offline_access and that token can be used to pull this information whenever it is needed without worrying about your token expiring.
Create an user just for your app and let the user authorize your app and get the access token and use it for this kind of data fetching. Some manual work but as long as you have some user authorized access token you should be able get the public contents.