Integrating the comment boxes
This one is fairly easy. Just register an app and grab a code from the Facebook Comments site, and paste the code to a suitable part of your page. There is a data-href parameter which has a sensible default, although it is best to set it manually. It might come handy when you are migrating to a new domain or reordering your structure, it also makes sure you see the comments in localhost.
Integrating the comment counts
A simple GET request gives back the comments count nested in a JSON object. No OAuth, no access keys needed, just a plain old XHR. Lets see a little example:
Graph API limits
Since we are using the Graph API here, we should take a look at the limits. There are several layers of limiting, and most are not detailed in the official site, the closest is 600 calls per 600 seconds, per token & per IP.
In this case, there is no application, since we did not include our appid. Also we do not use client access tokens, partly because we didn’t have one (you can if you ise Facebook login). So the effective limiting here is per IP, so it scales with the number of visitors. It is easy to test too: Just make a for-cycle to reach limiting, switch IP, and try again. With the new IP, the requests will be successful.
In conclusion, we should not fear running out of limiting using this method of getting the counts.
Integrating the comment counts sum
This is the part where things are getting interesting, but this is covered in a follow up article.