{"id":8879,"date":"2012-09-26T23:41:49","date_gmt":"2012-09-26T18:11:49","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=8879"},"modified":"2012-09-26T23:43:06","modified_gmt":"2012-09-26T18:13:06","slug":"reading-comments-of-linkedin-wall-post","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/reading-comments-of-linkedin-wall-post\/","title":{"rendered":"Reading comments of LinkedIn wall post"},"content":{"rendered":"<p>Hi,<\/p>\n<pre>\r\n\r\n<\/pre>\n<p>In one of my grails project, i needed to show the comments on any wall post of linkedin through API. I used the Java wrapper to connect any linkedIn account with the grails application which can be seen <a href=\"http:\/\/www.tothenew.com\/blog\/integrating-linkedin-with-grails-application\/\">here<\/a>. But somehow this library was not working when we need to fetch comments from any wall post and display them in our UI.<\/p>\n<pre>\r\n\r\n<\/pre>\n<p>I searched a lot about it but couldn&#8217;t find anything appropriate, then i decided to use the linkedIn API directly for retrieving the data. To make GET calls , i used the <a href=\"https:\/\/github.com\/facebook\/scribe\">Scribe<\/a> java library which can be downloaded from <a href=\"https:\/\/github.com\/fernandezpablo85\/scribe-java\/downloads\">here<\/a>.<\/p>\n<pre>\r\n\r\n<\/pre>\n<p>To make API calls on linkedIn, we need to have an authenticated account&#8217;s <strong>access_token<\/strong> and <strong>access_secret<\/strong>, which can be obtained by connecting a linkedIn account with the application as mentioned in this <a href=\"http:\/\/www.tothenew.com\/blog\/integrating-linkedin-groups-in-grails-application\/\">post<\/a>. <\/p>\n<pre>\r\n\r\n<\/pre>\n<p><strong>Code to fetch comments on LinkedIn Wall post :-<\/strong><\/p>\n<p>[java]<br \/>\nString consumerKey = CONSUMER_KEY \/\/ key obtained by linkedIn app<br \/>\nString consumerSecret = CONSUMER_SECRET \/\/ secret obtained from linkedIn app<br \/>\nString accessToken = &#8216;assess_token&#8217;<br \/>\nString accessSecret = &#8216;access_secret&#8217;<br \/>\nString postId = POST_ID \/\/ id of the wall post<\/p>\n<p> OAuthService service = new ServiceBuilder()<br \/>\n                .provider(LinkedInApi.class)<br \/>\n                .apiKey(consumerKey)<br \/>\n                .apiSecret(consumerSecret)<br \/>\n                .debug()<br \/>\n                .build();<br \/>\n String url = &quot;http:\/\/api.linkedin.com\/v1\/people\/~\/network\/updates\/key=${postId}\/update-comments?format=json&quot;;<\/p>\n<p>       OAuthRequest request = new OAuthRequest(Verb.GET, url);<br \/>\n        org.scribe.model.Token accessToken = new org.scribe.model.Token(accessToken,accessSecret)<br \/>\n        service.signRequest(accessToken, request);<br \/>\n        Response response = request.send();<br \/>\n        String jsonResponse = response.getBody()<br \/>\n         def updates = JSON.parse(jsonResponse) \/\/ contains comments data in JSON format<\/p>\n<p>          updates.values.each {def commentData -&gt;<br \/>\n                  println &quot;Comment : ${commentData.comment}&quot;<br \/>\n                  println &quot;Creator: ${commentData.person.firstName}&quot;<br \/>\n            }<\/p>\n<p>[\/java]<\/p>\n<p>This code will fetch the comments from any linkedin wall post. It worked in my case.<\/p>\n<pre>\r\n\r\n<\/pre>\n<p>Hope it helps.<\/p>\n<pre>\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Hi, In one of my grails project, i needed to show the comments on any wall post of linkedin through API. I used the Java wrapper to connect any linkedIn account with the grails application which can be seen here. But somehow this library was not working when we need to fetch comments from any [&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":4},"categories":[7],"tags":[769,771,1088,881,1089,1087,700],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/8879"}],"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=8879"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/8879\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=8879"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=8879"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=8879"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}