One of my biggest frustrations in adapting Facebook Connect into WordPress blogging has been the fact that most plugins out there either have too much, or too little incorporated into them. When you add more than one, you end up calling the Facebook Javascript Client libraries more than once, and often reinvent the wheel for what other people have done. I mentioned this in a wish-list I posted earlier. I want building blocks – I should be able to add a foundation, and add basic building blocks on top of that foundation to get what I want out of Facebook Connect on my blog.
Today I’m giving you that foundation. I’ve written a WordPress plugin called FBFoundations which sets up the bare-bones necessities of any Facebook Connect install. Once you have installed this plugin, the user can log in, and you have access to their login credentials from then forward to do whatever you want with. It’s a foundation – something to build a house on top of, and my hope is that many more FBFoundations-compatible plugins can emerge from this.
For instance, my next step will be to create a simple plugin for WordPress that uses the stream.publish API to post your blog to Facebook, and enable others to do so (tracking the number of comments and likes along the way if possible). There will be no need to add a user log in to that process, nor do I have to load the XFBML init scripts to render XFBML. It will all have already been loaded for me.
The script works a lot like Richard Miller’s “What Would Seth Godin Do” plugin from a UI perspective. At a default (you can configure this in your preferences) the first 3 times a user visits your blog they will be presented with a popup dialog box encouraging them to connect with Facebook. After those 3 times the popup no longer appears. There will also always be a “Connect with Facebook” login button above your comments (assuming they’re wrapped in a #commentform div) that will appear until the user clicks on it and logs in.
Using this plugin encourages each reader to log in through Facebook (remember – there are over 300 million Facebook users. Chances are most of your readers are on Facebook), and enables you to do cool stuff with each of those readers. Hopefully this will inspire others to make other FBFoundations-compatible plugins so we’re not re-inventing the wheel any more. Stay tuned for more plugins from me – what will you build with this as your foundation?
You can download the plugin here. Just download it and unzip it into your plugins directory in WordPress, activate it, and then add the API key for your website. (You’ll need to go to http://developers.facebook.com to add the developer app and add an app for your website if you haven’t done so already)
Or click here to download:
http://downloads.wordpress.org/plugin/fbfoundations-facebook-connect-plugin.zip
Please let me know in the comments if you see any issues. This is 100% GPL so please make your own adjustments and let me know if I can fix mine!
UPDATE – v0.4 – 10/26/2009: The popup is no longer default and can be turned on/off. Also added meta tag support and better compatibility with 3rd-party comment systems. See this blog post for more info on 0.4.
Here are some screenshots: