Search code examples
javafacebooktwitter

Java Library / API for share counts (count likes, tweets, +1s)


I've seen individual solutions to querying the tweet count, share count etc: Some are client side, some are server side, but they are all very simple and use public JSON / REST APIs

e.g.

How to get share counts using graph API

jquery plugin or routine to find tweet count

There is this GitHub project, but it's in Ruby (I need Java unfortunately, though I can use JRuby as a last resort) and also haven't been updated in 2 years (which is ages in terms of public APIs, e.g. Twitter)

Is there a any Java library that gets you the share / votes / likes / tweets count for any given URL?


Solution

  • Use the language of your choice to make a HTTP GET request like so:

    https://graph.facebook.com/fql?q=SELECT%20url,normalized_url,share_count,like_count,comment_count,total_count,commentsbox_count,comments_fbid,click_count%20FROM%20link_stat%20WHERE%20url='http://www.facebook.com/nokia'

    Or any url:

    https://graph.facebook.com/fql?q=SELECT%20url,normalized_url,share_count,like_count,comment_count,total_count,commentsbox_count,comments_fbid,click_count%20FROM%20link_stat%20WHERE%20url='http://nokia.com'

    Then parse the JSON.

    Paste that link to a browser and you'll see the JSON data