[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 FacebookI 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!
this is great! I will incorporate it into my next project. thanks!
I have not been able t make this code work for me so far.
I pasted the code snippit into a file, set_status.php, then put in my first name, email, and password between apostrophe marks, and finally executed the script like “php set_status.php” from the Terminal (I’m running OSX). The script printed the XHMTL of a webpage telling me I needed to log in first, and my status was not changed.
Also, apparently you can update your status message by sending an SMS message starting with “i am” or “@” to FBOOK (32665). Just another way to push updates onto facebook.
I will email you so we can talk.
Also, yes, sending a text message would work, but you would need access to an SMS gateway to do this through a program.
I have posted WORKING code. As Vincent noted, something was wrong. Wordpress messed up the source that I posted, but it is fixed now.
When I use PHP to login to facebook, it logs me out of facebook in my web-browser.
If you use the same cookie jar as your webrowser in the script, then this shouldn’t happen. I’ve had trouble doing this with Safari, because cURL can’t parse the .plist format it uses for it’s cookie jar. I believe Firefox uses a format for it’s cookie jar that cURL can understand, even on a Mac.
Also, it’s probably a good idea to only login if you have to. Facebook keeps you logged in for a very long time, but unfortunately does not support multiple logins. To tell if I’ve been logged out, I look at the of the page that curl gives me.
Personally I think facebook should support multiple logins, but unfortunately there’s nothing I can do about this.
Fantastic, thanks! I’ll see if I can’t persuade the Twitteriffic people to incorporate this.
I created a similar plugin for winamp that updates your facebook profile (but not in real time). You can see more here:
http://utoronto.facebook.com/apps/application.php?id=2455096081
Surely this script would have to be user run, meaning you’d have to visit the page it was running from every time you updated twitter. Meaning you couldn’t just take advantage of Twitter’s SMS or IM update features?
Inferno_str1ke: You could do it that way, or you could have it run automatically on the server using cron (non-windows) or scheduled task (windows). You could set the cron/task to run frequently or infrequently, depending on your habits.
No joy getting the script to work when I ran it from the browser. It seems to do something to my Facebook session as the next time I go to Facebook it asks for me to login, but the status hasn’t been updated.
Has anything changed on Facebook that might have made the script not work?
Man, this is awesome - too good you found this!!!!
(even tough I still wish they would publish an “official” API rather than using this technique. But nonethless, it works great! Thank you so much!
I just hacked together a C# port of your code in a WinForm, as described here: http://www.muscetta.com/2007/08/02/facebook-api-and-winform-experiment/
I will polish the code and post it soon.
Hi Christian, just wanted to drop a quick comment to say thanks for the above work/code - I’ve hacked it up into a widget for imified, so I can update my facebook status straight from msn/live messenger
Hi, I would like to use winamp + facebook plugin if you could post it.
Thanks
Hah! It is doable! Now I just have to make java do it…
Great script.
It doesn’t work if the status is empty (in this case there will be no fname and the pregmatch fails)
If you are interested, I wrote the code to use this with Twitter Tools to sync your Facebook Status to Twitter.
http://www.blakebrannon.com/2007/08/18/how-to-sync-facebook-status-with-twitter/
I have an app on Facebook that lists a user’s friends on his profile. When the user clicks on a friend’s name, I want the app to show in the profile box whether that friend is online. That would require retrieving the online status from the friend’s profile. I want to be able to do that without logging out the user (problem mentioned above). Is there a way to do that? Thanks.
Thanks for posting this… I used it to write a Perl script (using LWP instead of cURL) that updates Twitter and Facebook at the same time:
http://mogrify.homelinux.org/2007/08/29/update-your-status-on-twitter-and-facebook-with-perl/
You saved me a lot of work
I did find that the second request doesn’t appear to be necessary - Facebook includes the post_form_id in the response to the login request. Also, they don’t appear to care about the user agent string. I wonder if they’ve changed things a bit since you wrote this.
Anyway, thanks again.
This looks very handy! Thanks for sharing
just what i’ve been looking for…although i seem to have the same problem as a previous respondent. has the code snippet been updated in light of some of the comments made [specifically the comment made on 04.25.07 at 12pm]? if so, much appreciate the updates - currently the script appears to read and write the cookie but i can’t see any changes reflected in my facebook status…
thanks again for what appears to be a great workaround
Here is the status update code in an iMacros for Firefox version
http://forum.iopus.com/viewtopic.php?t=3527
Why would Facebook do this? Don’t they get that if you put it on the web you can never take it down again…
Hey. This might seem really random, but I was looking at a php script (http://textsnippets.com/posts/show/1204) that logs into Facebook to change one’s status msg. Your name was listed in the header comments, so I thought maybe you were the expert author.
Well, I have a small question and thought maybe you were the expert: I have tried many many attempts to merely login to Facebook using cURL. Essentially, the PHP curl uses curl-like functionality, but there isn’t a direct one-to-one mapping between the PHP curl calls to curl parameters. So, I was wondering if you knew were knowledgeable to help figure out what 1 line (or multiple?) cURL calls would log in to facebook. So far, the closest I’ve come is:
curl -L -e -v –cookie-jar “my_cookies.txt” –user-agent “Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20061201 Firefox/2.0.0.6 (Ubuntu-feisty)” -d “email=EMAILHERE” -d “pass=PASSHERE” -d “login=Login” “https://login.facebook.com/login.php?next=http://m.facebook.com/home.php ” > index.html
Any help would be greatly appreciated, and thank you very much in advance!
Sounds like the wankers at facebook are a bunch of morons. what fscking difference would it make to them if your code worked or not? people still have to use their site.
legally I don’t see how they possibly had a leg to stand on, the code was copyright to you and their application allow itself to be manipulated that way.
morons.
No problem - thats what the wayback engine is for.
The Old Page
Feel free to remove this comment if facebook makes any trouble about it.