Hacking Gmail

(Grace) #1

144 Part II — Getting Inside Gmail


$new_msgs++;
}
}
}

my $rss = new XML::RSS (version => ‘0.91’);

$rss->channel( title => “Unread mail count for $username”,
link => “http://gmail.google.com/”,
description => “The unread mail count for
$username”,
language => “en”,
);

$rss->add_item(
title => “You have $new_msgs messages”),
link => “http://gmail.google.com”),
);

print header(‘application/xml+rss’), $rss->as_string;

Installing this script on a web server and pointing your newsreader at the URL
produces a single-item RSS feed showing the number of unread messages in your
Inbox. It’s simple and unobtrusive in that way. The URL should be structured
like so:

http://www.example.com/gmail2rss.cgi?username=USERNAME&password=
PASSWORD

You build upon this script in later chapters.

New Mail Count to AOL Instant Messenger


As well as an RSS reader, you might also have an AOL Instant Messenger (AIM)
application running. In this section, you build two ways of receiving new mail
notification via AIM. The first is by using a script very similar to that in Listing
8-4. This one checks for mail, logs in to AIM, and sends you a message with the
number. You just need to set the script to run on a schedule, and it keeps you up to
date in a relatively painless way.

To do this, you first log in and check for new mail, as per the preceding scripts,
and then use the Net::AOLIM module to send the message. Like so:
my $aim_user = “”;
my $aim_password = “”;
my $aim_destuser = “”;
Free download pdf