If you’re developing for the Facebook API, you’ll have noticed by now that you probably want to have their F8 platform cache things in people’s profiles, using the ref FBML, which looks like this:
<fb:ref url="http://your-site.com/resource"/> <fb:ref handle="MyItemToCache#1"/>
With the ref-url construction, Facebook will visit your URL and cache it. You can call their API to refresh the url when you would like. With the superior ref-handle construction, you pass (handle, value) pairs to Facebook to cache. This saves you from being hammered by Facebook on all the refresh callbacks because you can just fire and forget your ref-handle updates.
Here is an example from my Stock Quotes Facebook Application, which refreshes its tickers on a regular interval:
Refreshed 1859 stock tickers in 5 seconds!
How on earth can I refresh 371.8 ref handles a second? You certainly can’t; the performance of the standard API is 4.60 ref handles a second. But, I’ve hacked the Facebook PHP Client to give you 80x the ref-refreshing performance. The trick is to parallelize the Facebook api calls, using curl_multi instead of plain old curl. You create a new Facebook API client called $fb and then:
$fb->openTransaction(); // your calls to set / refresh refs $results = $fb->closeTransaction();
You get back the $results array as well, which you can check for errors if you’d like. If you want, you can download my modified client for your own personal use. Please let me know if there are any bugs!
|This entry was posted on Saturday, June 16th, 2007 at 5:48 pm and is tagged with stock tickers, ref url, value pairs, facebook, fb, interval, personal use, lt, array, bugs, fbml, profiles, earth. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback.|