.

Monday, June 28, 2010

Facebook API - Server-side Personalization

Once you have hooked up single sign-on, you can increase the engagement on your site by personalizing the content on your site to a user based on her social graph. Every site is different, but the basic structure will likely look something like this:








// Fetch the user's friends                                                   
$friends = json_decode(file_get_contents(
    'https://graph.facebook.com/me/friends?access_token=' .
    $cookie['oauth_access_token']), true);
$friend_ids = array_keys($friends);

// Fetch all the content posted by this user's friends
$result = mysql_query('SELECT * FROM content WHERE uid IN (' .
                      implode($friend_ids, ',') . ')');
$friend_content = array();
while ($row = mysql_fetch_assoc($result)) {
  $friend_content[] = $row;
}

Check out the Graph API for all the data available in Facebook Platform, and check out the Platform showcase for inspiration from other sites who have used Facebook for personalization.


For more details ..
http://developers.facebook.com/docs/guides/web

0 comments:

Post a Comment

Facebook Twitter Delicious Digg More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Macys Printable Coupons