% twidge update "hello world"
I then think it would be a good idea if I can do the same thing with facebook i.e. to update facebook status right from command line. However, when I did search on google, I found nothing.
Well, actually, there is an indirect way by:
- Adding facebook application "Selective Tweet".
- With the same twitter account you use to add "Selective Tweet", whenever you append "#fb" to your tweet, that tweet will also appear on facebook status.
So what if I want to do it directly...
Recently, I had a chance to try out the Perl module "WWW::Mechanize" - Handy web browsing in a Perl object. It is a subclass of the well-known LWP::UserAgent module which is a User Agent module for Perl which we use to write robot, spider and such.
Here is the Perl script I use to update facebook status:
#!/usr/bin/perl
use WWW::Mechanize;
$mech = WWW::Mechanize->new;
$mech->agent_alias('Windows Mozilla');
$base_url = 'http://m.facebook.com';
# {{{ login
$mech->get($base_url);
$response = $mech->submit_form(
fields => {
email => 'your_email_address',
pass => 'facebook_password'
}
);
die $response->status_line unless $response->status_line;
# }}}
while (1) {
print "What's on your mind? : ";
$status = <STDIN>;
$response = $mech->submit_form(
fields => {
status => $status
}
);
die $response->status_line unless $response->status_line;
}
Here is what you will see when you run it:
unsigned_nerd@linuxsucks ~ % fbset
What's on your mind? : it's easier to update facebook status from command line
By the way, isn't it better if I use some Facebook API instead...? Umm... maybe later.
10 comments:
good!
OMG!
When I run this I get "No form defined at line 12" which is the login submit_form line.
hmm thanks for your comment. i have heard that a week or so ago, the mobile version of facebook (m.facebook.com) has been updated. i will check it later and let you know.
Thank you so much for taking a look at this. I have a sailing blog that I update via e-mail (via high frequency radio) while at sea and/or many of the places that I visit that don't have Internet.
The script that processes my e-mail is written in Perl and I wanted to add the capability of posting to FB that a new log was available. I'll starting heading down the Pacific coast of Mexico in about a week and won't have Internet for most of 4 months, but if this doesn't get done, it doesn't get done. There will always be next year...
I'll jump in and ask for an update to this. I've tried all kinds of scripts to do this, and this is the cleanest that I've seen. None of them seem to work anymore. If you could fix this, that would be very helpful!
Hi...
I can make it work now without modifying codes. It didn't work at first because I tested it on MacOSX which didn't have a module: Crypt::SSLeay.
Can you post your full error message again plus the system you are running on?
THanks
I added "use Crypt::SSLeay;" and I still get "No form defined at fb_status_update_3.pl line 13"
can you open this url: http://m.facebook.com from a web browser on the same machine where this fbset script runs on, view source and send me its content? r u using a proxy to browse website?
I'm trying to run this on a shared web hosting site (www.pair.com) and only have telnet access to it. I've used lynx and similar applications, but have no idea how to do a "view source". Any ideas?
Post a Comment