small perl (c-ish again I guess) script to get number of unread messages in facebook. for use with conky etc... supply username and pass as args.
#!/usr/bin/perl use strict; use WWW::Mechanize; use HTTP::Cookies; my $username = @ARGV[0]; my $password = @ARGV[1]; my $mech = WWW::Mechanize->new(); $mech->cookie_jar(HTTP::Cookies->new()); $mech->post("https://login.facebook.com/login.php?m&next=http://m.facebook.com/inbox",{email=>$username,pass=>$password}); $mech->content() =~ /Inbox\s\((\d+)\)/; print $1?("$1 New Message".($1>1?"s\n":"\n")):"0 New Messages\n";
4 Comments:
why not extend it to get email sender and subject lines as well?
I would, but like I said in the post before I'm new to Perl. I plan to look into it when I have some time on my hands as it's a feature that I originally wanted as well.
plus one for more features
this feature is not part of the facebook API so this "hackish" way of doing it is no longer necessary.
check out fbcmd
Post a Comment