Jul 16, 2009

Facebook inbox count for conky/others

YAFS again! I'll just throw this out there.

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:

Anonymous said...

why not extend it to get email sender and subject lines as well?

SoE said...

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.

g1mm3105 said...

plus one for more features

SoE said...

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