Handles are the key to having applications update on the profile page without a user taking action. Some notes on how to do this on Facebook are here. Since Bebo has implemented most of the Facebook API this should be easy but I think some things (like Infinite session keys) are still missing. Hoping someone will leave me pointer proving me wrong on this.
By placing a handle on a user’s page you can (in theory) push updates to a user’s profile page without them interacting with the application. For example. If you had a “Washington Capitals Fans” application that pushed news to every user’s profile that had the application, all these pages would have the same handle. Having a single handle means that a single update of the handle content would update all profiles using the application.
In other cases you might want a unique handle per profile. For example, if your application injected an RSS feed of the user’s choice onto their profile.
Here is a simple example of setting a handle on a user’s page. I use the user’s UID as the handle in this case.
I then write an update.php file that injects the date on the user’s profile
That’s all fine and good but the update wasn’t automatic. The user had to hit the update.php file. In a real application we would have a database of all the users and we could periodically update the handles. Assuming there is an infinite session concept in the Bebo API. Since I could not figure out how to implement an infinite session here is my hack.
I place a hidden image on the user’s page that calls the update function.
Now when a user views their profile, the hidden image calls refresh.php and the handle content is updated. Unfortunately, the update happens after the page is rendered so you’ll need to reload to see the change.
Unfortunately, the update happens after the page is rendered so you’ll need to reload the page to see the change. It should also be noted that anytime someone views your page they will call the update.php. If they also have the application installed your handle will be updated.
Assuming infinite sessions keys are unavailable I would leverage app users to update their peers. In your database of users keep track of the last time they were updated. Anytime the update.php function is called do an update on all handles that haven’t been updated in a specific period of time. As the user base grows this should allow for a more even distribution of updates. This might even be better than the cron jobs that infinite session key users use in their cron jobs.
Last week I spent some time learning how to build Bebo applications. Their API is just like the Facebook API but it is not complete and the documentation has some holes in it. If you haven’t built a Facebook application the entire process can seem awkward.
The Bebo Developer Page makes it sound like a simple 3 step process
- Get the library
- Install the app
- Start Creating.
If you don’t know how to write web applications in PHP, Java or Ruby stop now. You need to know at least one of these systems to continue.
I downloaded the PHP library and put it on my host. Next step was to install the developer application. Why? Why do I need to install an app to build apps? Seems weird at 1st but basically this application is used to manage the keys, locations and settings for your apps.
Once you have the app launch it and click “Create new app” (way off on the right) . Give your application a name and a URL and a callback URL.
What is the callback URL? It is the URL that is hit when a user goes to the Application URL. http://apps.bebo.com/yourappname is just a proxy that adds headers and parameters to the request before it hits your application file. The bebo library uses this information.
For example. I created an app called sample with a URL of http://apps.bebo.com/sample. My callback URL is http://bebo.tonycode.com/apps/sample
Hitting http://apps.bebo.com/sample results in a call to http://bebo.tonycode.com/apps/sample where I have the following index.php
This application simply prints out all your friends.
Add the application to your page by going to the developer application, viewing the app and clicking the profile page for the app. Now go to your profile page a voila.. the app is there but not your friends.
Huh? How do I get the content to show up on my profile page? If I don’t show it on the profile page it seems pretty pointless. right?
To add content to the profile page you use profile_setFBML. Last I checked the return codes for this function are not defined. Seems to return a 1 when it works and an array when it fails. Nice. :-\
Here is the code updated to put friends on profile too.
Weeks go by and you add new friends to your profile and you notice that the list of friends in your custom application aren’t changing. profile_setFBML is only called when you visit the application page. Well that stinks you say. How can I make it update each time I visit the profile? I’ll get to that in my next post.
- Documentation is at http://developer.bebo.com/documentation.html
- The downloaded libraries have example code. Start there
- You may need to look at 2 different sections to piece together how a function works. For example user.getInfo has a fields parameter
- Look at the SNQL users table to find what is available