{"id":6379,"date":"2012-08-24T20:35:31","date_gmt":"2012-08-24T15:05:31","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=6379"},"modified":"2016-12-19T15:16:40","modified_gmt":"2016-12-19T09:46:40","slug":"integrating-linkedin-groups-in-grails-application","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/integrating-linkedin-groups-in-grails-application\/","title":{"rendered":"Integrating LinkedIn Groups in grails application."},"content":{"rendered":"<p>Hi,<br \/>\nIn one of my recent Grails application, i needed to integrate LinkedIn groups with the application.<br \/>\nIn my previous <a href=\"http:\/\/www.tothenew.com\/blog\/integrating-linkedin-with-grails-application\/\">post<\/a>, we discussed about Integrating LinkedIn API in any grails application. To add a LinkedIn Group, we first need to authorize the LinkedIn account which has either created that group or is the member\/admin of the group with the rights to publish new post in that group.<\/p>\n<pre><\/pre>\n<p>After obtaining <strong>linkedIn_token<\/strong> and <strong>linkedIn_secret<\/strong> as mentioned in this <a href=\"http:\/\/www.tothenew.com\/blog\/integrating-linkedin-with-grails-application\/\">blog<\/a>, we need to make another call to retrieve all the Linked Groups for that account.<\/p>\n<pre><\/pre>\n<p>Code to retrieve all the LinkedIn Groups is as :-<\/p>\n<p>[java]<br \/>\n         String apiKey = API_KEY obtained from registered LinkedIn Application<br \/>\n         String apiSecret = API_SECRET obtained from registered LinkedIn Application<\/p>\n<p>        Map linkedInGroupMap = [:]<\/p>\n<p>        LinkedInAccessToken accessToken = new LinkedInAccessToken(linkedIn_token, linkedIn_secret)<br \/>\n        LinkedInApiClientFactory factory = LinkedInApiClientFactory.newInstance(apiKey, apiSecret)<br \/>\n        LinkedInApiClient linkedInClient = factory.createLinkedInApiClient(accessToken)<br \/>\n        GroupMemberships groupMemberships = linkedInClient.getGroupMemberships()<\/p>\n<p>       groupMemberships.groupMembershipList.each {GroupMembership groupMembership -&amp;gt;<br \/>\n            linkedInGroupMap[groupMembership.group.id] = groupMembership.group.name<br \/>\n       }<br \/>\n[\/java]<\/p>\n<p>So, the resulting map will contains the <strong>key, value<\/strong> pairs of linkedIn groups ID and Name.<\/p>\n<pre><\/pre>\n<p>Now we can store these Group IDs for making API calls to :-<\/p>\n<p><strong>#. Retrieve group&#8217;s profile details.<\/strong><br \/>\n<strong>#. Read, Create, Like, Comment group posts<\/strong><\/p>\n<pre><\/pre>\n<p>Example API call to retieve group&#8217;s discussion wall posts:<\/p>\n<p>[java]<br \/>\n     http:\/\/api.linkedin.com\/v1\/groups\/${linkedInGroupId}\/posts?format=json&amp;count=30&amp;start=30<br \/>\n[\/java]<\/p>\n<p>This will retrieve latest 30 group discussions in JSON format.<\/p>\n<pre><\/pre>\n<p>This worked for me. Hope this helps&#8230;:)<\/p>\n<pre><\/pre>\n<p>Useful Links:<\/p>\n<p>https:\/\/developer.linkedin.com\/rest<\/p>\n<pre><\/pre>\n<p>Cheers..!!!<br \/>\nVishal Sahu<br \/>\nvishal@intelligrape.com<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, In one of my recent Grails application, i needed to integrate LinkedIn groups with the application. In my previous post, we discussed about Integrating LinkedIn API in any grails application. To add a LinkedIn Group, we first need to authorize the LinkedIn account which has either created that group or is the member\/admin of [&hellip;]<\/p>\n","protected":false},"author":19,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":2},"categories":[7],"tags":[769,771,881,884,700,882,883],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/6379"}],"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\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=6379"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/6379\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=6379"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=6379"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=6379"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}