2

Is there a way realtime store/update Facebook api 'share', 'like' counts each pages on site to database? I just can't figure out how to, and can't see any example... so please any suggestion will be appreciate!!

for example it can be sort all data to solve like this How can I get the list of top 10 artciles shared on Facebook using Graph API or FQL?

UPDATE
If I want to sort all data, (https://api.facebook.com/method/links.getStats?urls=%%URL%%&format=json) I think maybe I have to store all data to my database,
Maybe it can't be possible realtime sync my database and fb database, because the share count number is include the Facebook user click shared post share button on Facebook.

If so, should I only use crontab execute php file get data store to my database. then I can print on web page? Or some other suggestion? people usually how to do this?

Community
  • 1
  • 1
user1775888
  • 3,147
  • 13
  • 45
  • 65
  • I think caching data in your database is good, because of performance. On server side you can run CRON at certain interval of time to gather the data, skipping what is already saved. – Qarib Haider Aug 05 '14 at 14:59

1 Answers1

0

The FB API allows you to subscribe to events, such as:

FB.Event.subscribe('edge.create', function(response) {
  // like clicked
});

You could from there send an AJAX request to your server, telling it to update the count in your database. This assumes that you're getting the likes primarily from your website, and not from Facebook.com. In any case, it could be used together with your cron job to provide some improvement.

graemeboy
  • 590
  • 4
  • 11