As you may recall, I wrote a post a few weeks ago waxing poetic about Facebook’s Graph API and their awesome new Social Plugins. After clearing my plate of a few larger projects, I set aside some time last week to see how hard it would be to integrate their new commenting system with the news, event and message pages on longhollow.com; turns out it wasn’t too bad, and they actually give you a surprising amount of control over the look and feel. Here’s how to pull it off for your ministry…
Step One: Create a New Facebook Application
Visit facebook.com/developers and click “Set Up New Application” in the top right corner of the page. Don’t be too freaked out by the intense geekiness of this part of the process, as you’re really just naming an application, uploading a few logos to use with it, and writing down a unique key to use with your new commenting system.
When you’re done here, be sure to copy and paste your Application ID, which you can find on the screen below:

Step Two: Update Your HTML Template
Before you add the Comments Box to your site, you’ll need to update the HTML templates where you’re adding Facebook Comments with Facebook’s JavaScript SDK. Again, this isn’t nearly as scary as it sounds.
Add the following line of code inside your page’s opening HTML tag:
xmlns:fb="http://www.facebook.com/2008/fbml"
Add their JavaScript SDK just after your opening BODY tag, and be sure to paste your Application ID in the appropriate location:
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'YourAppIDHere',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
};
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
Finally, add a few META tags to the HEAD of your page if you want to list stuff like your site’s name and an image to use when people “Like” and share your content:
<meta property="og:site_name" content="Your Site Name Here" />
<meta property="og:image" content="http://www.yoursite.com/path/to/image.jpg" />
Step 3: Customize and Embed the Comments Plugin
Still with me? Good… It’s pretty much smooth sailing from here on out. Now that you’ve created your application and prepped your page for the comments plugin, all you have to do is visit the Comments Plugin Page to generate your code. It will look something like this:
<fb:comments xid="1234" width="450" simple="0" css="http://www.yoursite.com/stylesheets/facebook_comments.css?1234"></fb:comments>
A few important notes here:
- The “xid” field is the unique id that’s attached to your string of comments. Change this and your comments are gone. If you’re placing comments on a page that’s generated dynamically, I’d try to generate some sort of unique alphanumeric key automatically.
- Remember that customization I mentioned earlier? This is accomplished by specifying your own style sheet in the fb:comments tag. The only catch here is that Facebook will automatically cache your style sheet, so you’ll need to append a variable to the URL every time you make a change to get Facebook to load the changes (hence the “?1234″ in my example above).
- If you’re building this on a testing server before you make it live on your site, don’t freak out if you don’t see the “Like” button directly above the comments. For some reason this wouldn’t show up for me until I rolled the plugin out to the live site (I’m guessing because Facebook couldn’t see my testing server in order to “Like” the page).

That’s all there is to it! We’ve had the plugin up and running on our site for about a week now (click here for an example), and we’re absolutely loving it. Most of our audience is already logged in to their Facebook account when they visit our site, so commenting and “liking” their favorite content is almost an afterthought. Even better, whenever they interact with our site, this activity is automatically published on their wall (pushing more folks back to our content). It’s a win for everybody.
Do you have this up and running on any of your online properties? Take a minute to show off your sites in the comments below.

Wonderful tutorial. Thanks !!
Good stuff Eric! Will be giving this a shot on my site soon, and possibly on all of the sites for our radio network at work.
Glad you guys like it; hope it’s helpful.
Eric, have you seen a way to use this in a similar way but to have the posts aggregate on the “fan” page (like? page) or even on a Group discussion page? I’ve had someone ask about that, but I’m having a hard time finding definitive info from Facebook Dev site. Good work.
Kevin:
No, the closest thing I’ve seen to that is the old “Like Box,” which is pretty much read-only from your page. Seems like an obvious piece of functionality though, you know?
This is a great tutorial. Thanks to inspiration from Eric the other day, we’re using this on a series minisite at The Chapel. http://Chapel.org/sinai -> click on “Your Thoughts.”
OMGsh…that was one of the best posts ever!! Thanks Cleve. So helpful!
great stuff, I must give that a try.
apparently there are other things that you can do with the api to your facebook page, like getting the fan_count - still trying to get that right
any thoughts on getting this integrated with WordPress? if code is in a single post (.php page) then it crosses comments amongst all of the posts…
great tutorial - really enjoyed learning as I walked through it…
How you holding up? to Uh, Chelsie, just how fed-up are you with Jake Pavelka? to Hey, Erin and Maks, the rumors,” said Andrews. What do you make of the Erin and Maks andThe latest news, video clips, photos, and rumors about Erin Andrews-plus related General stories on BallHype Free Erin Andrews Peephole 2 Apr 2010 (AP) - An attorney for Erin Andrews says the ESPN reporter and “Dancing with the Stars” contestant has been getting death threats. Espn Erin Andrews Peephole Video
see more:
Espn Reporter Erin
Erin Andrews Peephole Video Photos
I have gotten this to work. However, I’ve been unsuccessful at styling it. The widget seems to be picking up on the default link colors of the site but I can’t change them or anything else. Any ideas on how to overide this? I have looked at the source and tried all types of variations, along with updating the CSS url (because of FB cache syndrome).
It’s surely getting easier to implement Facebook into websites, but they need to let go a little bit as it’s still a pain in the behind to do anything with it… compared to other API’s.
Great article. I recently set it up on our retreat website and have noticed it being a lot more useful than standard WordPress or Disqus. In the past a comment was just a comment, but since I’ve switched it to FB comments a comment is also an opportunity for more exposure. The only thing I wish was that it would notify me when people post on the website. Maybe it can but I haven’t found it yet?
Here is a link to our testimonial page where people are using it: http://www.oasischristiancenter.com/testimonials/
Great post Eric.
I’m pleased you took the time and wrote this!
Kind regards
Davidoff Cigar