Forum Moderators: coopster
I wonder if anyone can help me. The users on my site are allowing me to show other users their MSN messenger status (whether it be offline, online etc).
I would like to put people that are online on MSN messenger in a seperate list using MySQL.
I know the url that I should checking for their status and MSN returns an image.
I would like a way via PHP to:
if($msn_return == ""){
// change status in db here
}
but how do you check if a variable equals an actual image rather than a value.
if i echo $msn_return all i get is a load of symbols which i guess is the text version of the image.
Any help would be much apreciated.
Thanks
Seamless.
I know the url that I should checking for their status and MSN returns an image.
You might want to perform a regex on where you expect to see the image, and see whether it's the 'online' or 'offline' image.
/edited
I meant in the sense of viewing a 'profile', but since you're viewing simple a returned image file, perhaps there is something in the heads that indicate whether it's the online or offline image, i.e. filesize
otherwise you could do an MD5 of the image file, it should return two values
[edited by: brotherhood_of_LAN at 9:43 pm (utc) on Nov. 11, 2008]
You might want to look into using cURL [uk2.php.net] for URL fetching as it's rich in customisation and will allow you to make HTTP/1.1 and HEAD only requests.
Otherwise something like this:
echo md5(file_get_contents($url))
I'm thinking you should get 2 MD5's returned, one for the online image and one for the offline one.
I was able to determine the different md5 values for the different status' and use that.
function msn_status($msn){
$offline_status = array("ae1daee572ed6b1e8d19e27a70bcc676",
"20babb80e0a673174d8ecd538f173066",
"ae1daee572ed6b1e8d19e27a70bcc676",
"8a485b75acb289c87f4a2d94867338c9");
$online_status = array("1655410ae3015b6b1df7543e8357001b",
"b938fb7ad566838506defcf7af075d68",
"13ac99d606d9c30a4b8226cd47164f1b",
"73c4845f0b1bfe095224ccfcb415f8ed",
"5a144da553be66596505a92428dbf518",
"b938fb7ad566838506defcf7af075d68",
"cc97d7a872731601945917fd6b6a927a",
"73c4845f0b1bfe095224ccfcb415f8ed",
"be168b5c4e424b55c3961f1410d6e7f2",
"449085118397a452cb91c8e2e3b7a2e6",
"8ffbeb473e9e1b28efc14aafc2e57f2d",
"b938fb7ad566838506defcf7af075d68",
"c0da67babe50fefeb151b3f92c4e7c0c");
$url = "http://messenger.services.live.com/users/".$msn."/presenceimage?mkt=en-GB";
$md5 = md5(file_get_contents($url));
if(in_array($md5,$online_status)){
return 1;
}elseif(in_array($md5,$offline_status)){
return 0;
}else{
return 0;
}
}
Thanks very much for your help!
Seamless