Question

I want to ready ONLY public Posts and User's profiles of those Posts from Facebook using Graph (search) API.

And I am little confused over which access token I need , do I need User Access Token or Application Access Token ?

My application is Java based console/desktop application and I am using RestFB.

Please guide me here to how to get my required information and most importantly if I require a User Access Token , then how can I automate this process in my application using RestFB (or any other Java Facebook lib)?

Please note that this is a console application (will run on server) not a client application so what I can do is to create a dummy facebook user account and generate User Access Token using that dummy account.

Thanks, Tony

Was it helpful?

Solution

Try read the documentation about tokens, you have four types of tokens. See what suits best for you.

User Access Token – The user token is the most commonly used type of token. This kind of access token is needed any time the app calls an API to read, modify or write a specific person's Facebook data on their behalf. User access tokens are generally obtained via a login dialog and require a person to permit your app to obtain one.


App Access Token – This kind of access token is needed to modify and read the app settings. It can also be used to publish Open Graph actions. It is generated using a pre-agreed secret between the app and Facebook and is then used during calls that change app-wide settings. You obtain an app access token via a server-to-server call.


Page Access Token – These access tokens are similar to user access tokens, except that they provide permission to APIs that read, write or modify the data belonging to a Facebook Page. To obtain a page access token you need to start by obtaining a user access token and asking for the manage_pages permission. Once you have the user access token you then get the page access token via the Graph API.


Client Token - The client token is an identifier that you can embed into native mobile binaries or desktop apps to identify your app. The client token isn't meant to be a secret identifier because it's embedded in applications. The client token is used to access app-level APIs, but only a very limited subset. The client token is found in your app's dashboard. Since the client token is used rarely, we won't talk about it in this document. Instead it's covered in any API documentation that uses the client token.


You can read a more detailed info of each token here https://developers.facebook.com/docs/facebook-login/access-tokens/

If this is much complex for you, you can get the public posts of pages using rss feed. You either can have a xml or a json format.

XML https://www.facebook.com/feeds/page.php?id=PAGE_ID&format=rss20
JSON https://www.facebook.com/feeds/page.php?id=PAGE_ID&format=json

Where the PAGE_ID is the id of the page you desire, for example this two urls give you the public posts of John Frusciante's page

XML -> https://www.facebook.com/feeds/page.php?id=122854921087972&format=rss20

JSON -> https://www.facebook.com/feeds/page.php?id=122854921087972&format=json

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top