Reputation: 13824
If you using Facebook graph API, you can see all public information of someone if that person set those information public, only few things you need to do: open a browser, log-in to Facebook and know that person user ID#, for example, Mark Zuckerberg - facebook founder have user ID# 4, so go to: https://graph.facebook.com/4 => you can see basic info such as name, age, location .... (imagine that you change i in _https://graph.facebook.com/i with i from 1 to 1 million, you may see info of million user as long as they set their info in public)
or go to this link you can see more information such as person favorites and education ... _https://graph.facebook.com/4?access_token=XXX with XXX is a unique code, it changes every time you log-in to Facebook ( see more in http://developers.facebook.com/docs/reference/api/)
My goal is using basic java url to go to these link and get all info (basically they are text) and save them to a text file, with _https://graph.facebook.com/4 there is no problem but with second link problem is the access token code which is XXX - changes every time or will be expired after 20~30 minutes so I can't run my program longer to get more data. question is is there anyway to get a permanent access token or extend it for longer time, remember I only using a small java program, nothing to do with Facebook app or anything else. Thanks in advanced!
Upvotes: 2
Views: 4409
Reputation: 11
You can extend the life of your access token to 60 days. You can go through this:
https://developers.facebook.com/docs/facebook-login/access-tokens/
If you make the following call from your server side, Facebook will return you an access token which will be valid for 2 months (extended access token):
GET /oauth/access_token?
grant_type=fb_exchange_token&
client_id={app-id}&
client_secret={app-secret}&
fb_exchange_token={short-lived-token}
Upvotes: 1
Reputation: 2153
You cannot get a permanent access token, but it is quite easy to renew after its expiration: That article is the way to go. The magic URL is:
https://www.facebook.com/dialog/oauth/?client_id=YOUR_APP_ID&redirect_uri=YOUR_REDIRECT_URL&state=YOUR_STATE_VALUE&scope=COMMA_SEPARATED_LIST_OF_PERMISSION_NAMES
client_id
redirect_uri
Call the link above with a webbrowser, use http://localhost
as redirect_uri and you'll be fine. The browser will attempt to call http://localhost#access_token=....
and obviously fail, but you can parse the url to get the token. It is not a very straightforward process, but it works for me.
Upvotes: 0
Reputation: 1456
Unfortunately you can't get a permanent access token but instead you can catch the error when the access token is expired and request a new one. Also you might want to read facebook terms of use to make sure you are not violating it.
Upvotes: 2