Updating Facebook status using PHP
Friday, April 20th, 2007[UPDATE: October 01, 2007 @ 11:09am EST]
Facebook has officially implemented a users.setStatus() method in their API. Read more…[UPDATE: September 04, 2007 @ 7:21pm EST]
It is with great disappointment that I must make this announcement. Facebook has requested that I remove the code from my website. They have also contacted everyone else who has found my code and publicly mentioned that they are using it. I originally did not comply, but my Facebook account was disabled and legal action was about to be pursued.I am saddened at this turn of events because the idea behind the code was to extend Facebook’s current service and fill in the gap that their API had. The API still does not provide a means for updating ones status.
To everyone who found my code useful, everyone who ported my code to various other languages, those who integrated my code into their projects, and those who believe in Federated Status, Thank You.
- Christian Flickinger
I use Facebook as my ’social network of choice’, and the means for updating friends of my status. The main reason is because most of my friends have no idea what Twitter is, nor would many of them use it. Everyone I know does have a Facebook account though, so it seems only natural that I use the medium which will give my updates the largest audience.
Although I do not use Twitter, I fully support it and love the idea of it.
Out of curiosity, I wanted to see if I could meld Facebook and Twitter. What I envisioned was a one-stop shop for updating my statuses across the internet. To do this you would need something that can PUSH and ACCEPT updates. Twitter has an API that will ACCEPT updates, but nothing that will PUSH them. Facebook has an API that does not have any functions for status updates at all, but they do have status update RSS feeds. I want Twitter to be the top of my update tree. I want to update twitter (because of its SMS/Web/IM/API updating capabilities) and have everything else know about it. The API allows me to make a plugin for my IM client that could possibly throw my latest away message up on Twitter. SMS/Web/IM allow me to update twitter from wherever I am.
The problem with Facebook: You can only PULL status updates, and until now, you can not UPDATE them programaticaly. Searching google I quickly find a way to manually post my Facebook status to Twitter and a post that lays out the possibilities for facebook-twitter integration.
Well, I do not give up that easy. I want a way to update Facebook without physically logging into Facebook. It can be done, and I found out how. Facebook has no status update API and their update box uses AJAX to post, so cURL is out of question… or so everyone thought! Facebook has a mobile service (http://m.facebook.com) that allows you to update your status and view your Facebook from a cellphone. It looks the best on Windows Mobile devices (I have a Q), and works great on normal WAP browsers. This is the key to my facebook-twitter hack.
Facebook mobile uses a normal POST method for updating status. How cool is that? This means that it HAS to be possible to update your Facebook from a program. Using nothing but cURL (or, in my case, PHP with the cURL extension), you can update your Facebook status. What does this mean? This means that if someone wanted, they could easily keep their Facebook status synced up with their latest Twitter status. The code is below. Feel free to use it. Mentioning my blog/name would be greatly appreciated.
// Code removed at request of Facebook
I have already created my first test mashup of Winamp & Facebook, successfully displaying, in real time, the current song I was listening to in Winamp as my Facebook status. Anyone with some experience could easily use the above code to check Twitter and (if updated) push to Facebook. Happy mashing!