Archive for October, 2007

Ganging Up on Facebook

1_google_logo.jpgYesterday I read this interesting article titled Google and Friends to Gang Up on Facebook. The basis of the article was Google’s new alliances, which they hope will give them a way to take on Facebook. Specifically, Facebook’s recent decision to allow developers the ability to write against the Facebook platform API. The article states that Google will “introduce a common set of standards to allow software developers to write programs for Google’s social network, Orkut as well as others, including LinkedIn, hi5, Friendster, Plaxo and Ning.” As a software engineer I am fascinated by the potential this has for creating valuable applications that have both social networking value as well as business productivity value.

Facebook - fbml_refreshImgSrc

Maybe its just a temporary thing, but lately the Facebook server has had major issues with caching images.  If you are unaware, all images that are placed within a users profile page get scraped by Facebook and served up from their own internal servers.  If for some unforeseen reason there scraper fails your image gets replaced with an invisible pixel spacer gif.  To force the cache to update you have to manually call the fbml_refreshImgSrc method on their REST server.  The easiest way to accomplish this is to create a dedicated page that uses an infinite session.  Here is the PHP page I created to update the images as necessary.

1
2
3
4
5
6
$myClass = new my_class($api_key, $secret); 
//this sets a user and session 
$myClass ->facebook->set_user($global_user, $global_session); 
if(isset($_GET['url'])) { 
  echo '' . $myClass ->facebook->api_client->fbml_refreshImgSrc($_GET['url']) .''; 
}

Facebook - feed.publishTemplatizedAction

This past week Facebook added a new method on their REST server for sending news and mini feed stories. The method is “feed.publishTemplatizedAction” and the intent of this method is to replace the existing “feed.publishActionOfUser” with a method that is more “templatized”. Here is a sample we created which is a combination of static text and data we gathered from a RSS feed. When a users first installs our application we will publish this news story.

1
2
3
4
5
6
7
8
9
10
11
12
13
actor_id: 555555555
title_template:   {actor} <fb:if-multiple-actors>are<fb:else>is</fb:else>
           </fb:if-multiple-actors> exploring the web’s premier collection of 
            student-produced digital media Made on a Mac. 
title_data: 
body_template: <b>"{title}"</b> Made by <i>{author}</i>  
           - See it at the <a href="http://url/item.php?itemID={id}">
           Apple Student Gallery</a> 
body_data: {"title":"Lost", "author":"Jared A. Jaworski","id":13243} 
body_general: 
image_1: http://url/resize3.php?image=/109.jpg 
image_1_link: http://url/resize4.php?image=/109.jpg 
target_ids:

Sample
As illustrated in the sample, if multiple users publish stories where both the title_template and body_template markup strings are identical, as well as the title_data and body_data arrays, then Facebook may aggregated the stories together. When this occurs, the {actor} token is replaced with the names of all of the users whose actions are being aggregated. Also note, that the only valid HTML tags supported in the template is the <a>, <b> and <i>.

For more information check out Facebooks wiki at Feed.publishTemplatizedAction

Facebook Developer’s Garage - Phoenix

Facebook - Developers Garage - PhoenixOn November 14th @ the Tempe Center for the Arts Terralever will be hosting Phoenix’s inaugural Facebook Developer’s Garage. Anyone who is interested in diving deep into the Facebook Platform is welcome to join. The event is a forum to share ideas with local developers and listen to interesting presentations on the planning, development, implementation, and marketing of Facebook applications.

To see more details and RSVP, follow the link below:
http://www.facebook.com/n/?event.php&eid=5321528989

Facebook <fbml:ref../>

For those of you who have embarked on writing a Facebook app, you may have faced the challenge of how to automatically update your profile fbml without forcing a user to take action. The approach I have found most effective is to use the <fbml:ref> tag. Facebook defines this command as a tag which “fetches and renders FBML from a given ref source – either a ref string “handle” you’ve created using fbml.setRefHandle or a URL that serves FBML. ” When using “fbml.setRefHandle” Facebook stores this FBML on its servers in the form of a hashtable. Using a single push we can update FBML for all users that have our application installed.

For a recent client we were asked to display the first few entries from a RSS feed within a users profile. All Facebook users would see the same entries, until the RSS feed changed. Here is the PHP we used to set a users FBML.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function render_ref_fbml($uid, $rssItems) { 
  global $facebook; 
  try { 
    // Set FBML Cache 
    $refFbml = render_narrow_fbml($id, $rssItems); 
    $refFbml .= render_wide_fbml($id, $rssItems); 
    $facebook->api_client->fbml_setRefHandle('RssFbml',$refFbml); 
    // Set Profile FBML 
    $fbml = render_css_style(); 
    $fbml .= '<fb:ref handle="RssFbml">'; 
    $facebook->api_client->profile_setFBML($fbml, $uid); 
    } catch (Exception $e) { 
      error_log($e->getMessage()); 
    } 
}

In a standalone php file we then created a similar function which updated only the FBML stored under the “RssFbml” handle.

1
2
3
4
5
6
7
8
9
10
11
function render_ref($rssItems) { 
  global $facebook; 
  try { 
    // Set FBML Cache 
    $refFbml = render_narrow_fbml(0, $rssItems); 
    $refFbml .= render_wide_fbml(0, $rssItems); 
    $facebook->api_client->fbml_setRefHandle('RssFbml',$refFbml); 
  } catch (Exception $e) { 
    error_log($e->getMessage()); 
  } 
}

This php file uses an infinite Facebook session and is called every 30 min by a CRON job.

1
30 * * * * php -f /var/www/rss.php