View Single Post
02-10-2007, 12:59 AM
#4
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

Yes, you can query Yahoo for anyone's online status. Here's a Perl script that I wrote ages ago (I don't know Perl much at all, so it's probably not ideal).

Code:
#!/www/perl/bin/perl

use LWP::Simple;
use URI::Escape;

# If no querystring provided (for username), exit.
if (length ($ENV{'QUERY_STRING'}) == 0) {
	print "Content-type:text/html\n\n";
	print "Please specify whose online status you want to check.";
	exit;
}

# Yahoo! URL to query
$URL = "http://opi.yahoo.com/online?m=text&u=";

# Get username from querystring (lowercase and strip spaces)
$username = lc(uri_unescape($ENV{'QUERY_STRING'}));
$username =~ s/\s+//g;

# Fetch content from Yahoo!
$content = get($URL . $username);


# Begin output
print "Content-type:text/html\n\n";
if (index($content, "NOT ONLINE") == -1)
{
	# Do something if user is online
	print $username . " is ONLINE";
}
else
{
	# Do something if user is offline
	print $username . " is  OFFLINE";
}