curl-and-php
Online Status Indicator Alternate
Date: Sun, 30 Jan 2005 00:54:57 -0500
Hi there.
I'm a relatively seasoned PHPer, but new to cURL. I've only used cURL to
repost variables to another script (which I had failed to do).
So now I'm working in PHP to create an AIM, Yahoo!, MSN messenger online
status indicator. So if you are online it shows graphic A, if you're off
line, graphic B.
So the PHP version using fsockopen isn't working 100% with yahoo. So I'd
like to see if the alternative (cURL) would work.
I need some help though.
How would I go about transferring this from PHP to cURL?
if($medium == 'yahoo'){
$yahoohandle = fsockopen("opi.yahoo.com/online?u=".$uid."&m=t",
1, $errno, $errstr, 30);
if (!$yahoohandle){
echo $yahoohandle
.'Could not connect to Yahoo!<br />'
.$errno.' :: '.$errstr;
}
else{
$page = file_get_contents($yahoohandle);
print($page);
fclose($yahoohandle);
if (strstr($page, "ONLINE")){
$filename =
"/images/status_icons/yahoo_online.gif";
}
else{
$filename =
"/images/status_icons/yahoo_offline.gif";
}
$imagehandle = fopen($filename, "r");
if(!$imagehandle){
echo('Image could not be opened');
}
else{
$len = filesize($filename);
$image = fread($imagehandle, $len);
}
fclose($imagehandle);
return $image;
}
}
Thanks for your help.
~Brett
Received on 2005-01-30