{"id":2108,"date":"2010-11-14T22:02:00","date_gmt":"2010-11-14T16:32:00","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=2108"},"modified":"2010-11-14T22:02:00","modified_gmt":"2010-11-14T16:32:00","slug":"integrate-java-application-with-facebook-using-graph-api","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/integrate-java-application-with-facebook-using-graph-api\/","title":{"rendered":"Integrate java application with Facebook using graph api."},"content":{"rendered":"<p>These are few basic steps which will help you to integrate your java application with facebook using facebook graph api.<\/p>\n<p>Steps :<\/p>\n<p>1) Register your application at <a href=\"http:\/\/www.facebook.com\/developers\/\">http:\/\/www.facebook.com\/developers\/<\/a><br \/>\n2) Facebook will return Consumer Key and Consumer Secret for your application.<\/p>\n<p>3) Create a login action:<\/p>\n<p>String facebookPermissions = <a href=\"http:\/\/developers.facebook.com\/docs\/authentication\/permissions\">FacebookPermissions<\/a><\/p>\n<blockquote>\n<pre lang=\"groovy\">\r\n\/\/ Login Action\r\nString callbackUrl = \"ApplicationUrl\/controller\/action\"\r\nString facebookAuthorizeUrl = \"https:\/\/graph.facebook.com\/oauth\/authorize?client_id=FacebookApiKey&redirect_uri=callbackUrl&scope=facebookPermissions\"  \/\/             \r\nredirect(url: facebookAuthorizeUrl)\r\n<\/pre>\n<\/blockquote>\n<p>4) Create a callback action .<\/p>\n<blockquote>\n<pre lang=\"groovy\">\r\n\/\/\/  Call back action: Where the facebook will redirect after succesful authentication.\r\n\r\nString authCode = parms.code\r\nString facebookTokenUrl = \"https:\/\/graph.facebook.com\/oauth\/access_token?client_id=FacebookApiKey&client_secret=FacebookSecretKey&code=${authCode}&redirect_uri=callbackUrl&scope=facebookPermissions\"            \r\nURL url = new URL(facebookTokenUrl)\r\nString response = url.text\r\n\/\/ Retrieve the access token from the response\r\n\r\n<\/pre>\n<\/blockquote>\n<p>6) Persist the access token for future use.  The  access token never expire until the user explicitly rejects the application from his settings.<\/p>\n<p>Hope this helped!<\/p>\n<p>Cheers!<\/p>\n<p>Anshul Sharma<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 = [&hellip;]<\/p>\n","protected":false},"author":21,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":13},"categories":[1],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/2108"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=2108"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/2108\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=2108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=2108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=2108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}