0
votes

I've found a couple of ways to get Facebook stats for a given URL. Both of these work - I'm not sure if one is preferred:

https://api.facebook.com/method/links.getStats?urls=http://www.stackoverflow.com&format=json

https://api.facebook.com/method/fql.query?format=json&query=SELECT%20url,like_count,share_count%20FROM%20link_stat%20WHERE%20url%20=%20(%27http://www.stackoverflow.com/%27)

We run this on a cron that checks all recent content. We've done a fair amount of experimenting with when to stop checking content (we decided to stop checking content published more than 72 hours ago). We're also running this every 30 minutes and it checks around 100-200 URLs on each run. Unfortunately, we're often getting the error "Application request limit reached".

To get around this, I found it's possible to amend both of the above requests to look at multiple URLs in a single request. The links.getStats method is easy; you can add more URLs separated by commas. For the FQL request you can do this:

https://api.facebook.com/method/fql.query?format=json&query=SELECT%20url,like_count,share_count%20FROM%20link_stat%20WHERE%20url%20IN%20(%27http://www.stackoverflow.com/%27,%27http://www.google.com/%27)

This is quite handy! But does anyone know if querying in this way would count as one API request or two ? It looks at two URLs, but it is one request to fql.query...

If it's treated as one request, this seems like a good way to limit the number of API request errors we are seeing.

1

1 Answers

1
votes

The REST API which you are using is deprecated, which means that it can be deactivated without notification. Apart from that, your last request should be counted as one request IMHO.

I'd recommend you to switch to the current Graph API, as described here: