Connecting to the Facebook API
Facebook has a lot of data available to website developers through their Open Graph API, and Facebook also offers a ton of nice features to web developers to tie into Facebook's user profiles, commenting system, 'Like' system, etc.
While it may be argued how tightly your site should integrate with Facebook for a user's interaction with your site (do you really want something as essential as login to depend on an external service?), it is not a hard decision to allow some degree of Facebook integration with your site—after all, many of your site's users are likely Facebook users already, and they will be more likely to already be familiar with Facebook functionality and terminology.
To get started integrating Facebook features into your site, you can read through Facebook's Developer documentation, and after you have set up your own Facebook account, you can add the 'Facebook Developer App' to your profile, then click the 'Set Up New Application' button to add an App to facebook that integrates with your website (for the App's title, enter the name of your site, or whatever you'd like).
If you're using PHP for your website (who isn't?), you can download Facebook's PHP SDK, and get started building Facebook integration into your website.
An example of Facebook integration offered on Open Source Catholic is the fan page follower counts for the Archdiocese of Saint Louis. Following kovshenin.com's guide "How to Count Facebook Fans," we came up with the following PHP code to get a follower count for a particular page:
<?php // This is where you put the facebook.php file downloaded from the Facebook PHP SDK site require_once(‘sites/all/libraries/facebook-php/src/facebook.php’);
$facebook = new Facebook(array( ‘appId’ => ‘YOUR_APPID_PASTED_HERE’, ‘secret’ => ‘YOUR_SECRET_PASTED_HERE’, ‘cookie’ => true, ));
$result = $facebook->api(array( ‘method’ => ‘fql.query’, ‘query’ => ‘select fan_count from page where page_id = YOUR_PAGE_ID_PASTED_HERE;’ ));
$fb_fans = $result[0][‘fan_count’];
print ‘<p>The Archdiocese of St. Louis has $fb_fans Fans.</p>’; ?><h2>Other Facebook Features</h2>
One of the easiest parts of Facebook you can integrate is the 'Like' button - Facebook lets its users 'Like' any page, comment, status update, etc. across the web, and you can embed a small snippet of code in your blog or website to allow users to 'Like' a page.
For instance, here's a like button embedded on this page:
More information about the Like button, and other simple Facebook feature integrations, can be found on Facebook's "Facebook for Websites" page.