Integrate java application with Facebook using graph api.
These are few basic steps which will help you to integrate your java application with facebook using facebook graph api.
Steps :
1) Register your application at http://www.facebook.com/developers/
2) Facebook will return Consumer Key and Consumer Secret for your application.
3) Create a login action:
String facebookPermissions = FacebookPermissions
// Login Action String callbackUrl = "ApplicationUrl/controller/action" String facebookAuthorizeUrl = "https://graph.facebook.com/oauth/authorize?client_id=FacebookApiKey&redirect_uri=callbackUrl&scope=facebookPermissions" // redirect(url: facebookAuthorizeUrl)
4) Create a callback action .
/// Call back action: Where the facebook will redirect after succesful authentication. String authCode = parms.code String facebookTokenUrl = "https://graph.facebook.com/oauth/access_token?client_id=FacebookApiKey&client_secret=FacebookSecretKey&code=${authCode}&redirect_uri=callbackUrl&scope=facebookPermissions" URL url = new URL(facebookTokenUrl) String response = url.text // Retrieve the access token from the response
6) Persist the access token for future use. The access token never expire until the user explicitly rejects the application from his settings.
Hope this helped!
Cheers!
Anshul Sharma
i am using same api for FB login but i m facing an problem me getting null in session after successful authentication
I did not understand facebookAuthorizeUrl action. where it is defined and how will I use this?
Cool post. I have a site too. it’s about Twitter Followers, how you can build them and use this traffic source for monetization. Check it out, more traffic means more cash!
Hi anshul ….could u plz give me the step by step procedure …how to login into my java application via facebook account…plzzzzz
hi men, I need download the api for JAVA, know you authentic users with a aplication of desk? please guy, is for my proyect of the university.
thanks