Wednesday, February 22, 2012

"Facebook shares" retrieve in a back end

Sometimes you need to get Facebook shares number of you pages in back end. I was need it for performance reason, it faster to preload this data from Facebook in to Domino document and then show it.

There are two way to do it:


You could find examples and explanation following

Within FQL you could get shared statistic divided by "share", "like", "comment" and also sum of them.

Graph API

Look for"id" query.

Graph API as well as actual "like button" widget shows "total_count" number.  Some people think this is not completely correct, but Facebook developers suppose it's correct.

Example of  read shares from java under the cut

Graph API returns data in JSON fromat. Douglas Crockford create a good Java API for operation with JSON. I create jar from that source. You could download it from my file storage.

So, Facebook Graph API and JSON example of reading shares number:

Result of work:


Shares: 8 

Branch example:


Shares of 3198837

Shares of 8

Shares of 1010668

No comments: