|
The Yahoo messenger [online/offline
status indicator] is sometimes a bit too plain or the images not quite what
your looking for.. here are some revisions of how to use/customize it...
Sent in by Tendice
I found a way to indicating "Online"/"Offline" message
in HTML pages.
The key is the URL http://opi.yahoo.com/online?u=USER_ID&m=MODE&t=TYPE
where:
USER_ID is Identification of user we want to see if she/he is online
or not
MODE is the mode of information that Yahoo! sever return from its CGI
(online). Default is text,
and "g" uses for Graphics
TYPE is the Type of Picture we want to obtain (0 for icon, 1 for small
and 2 for large) Default is
0 and all number grater than 6 may have the same results as 0. You may use this
if
you set m=g in the URL above.
so,
if I want to have a custom image about my status I type this URL in my browser:
http://opi.yahoo.com/online?u=USER_ID
Then the server return me:
USER_ID is online
or
USER_ID is not online
When I want to implement it in my pages, simply get recent string and test it
to find "not" substring is in it or not. I can initialize everything
from here, for example to showing another Image or doing some actions.
Tendice!
Alissa also feels the same way and has spiced it up a bit with her own images..
This article has been written
by Alissa and is her own work (© Alissa 2001), she has submitted it to us for
inclusion on our site for which we thank her...
I wanted to have the Yahoo online / offline notification on my site, but wanted
to use custom graphics. I ended up, (with some help,) writing a PHP program
to do it.
My custom example is [HERE],
if you want to take a look. Scroll down and it's on the left. I am going to
re-do the graphics again in the near future.
A quick note - as I said, the program is written in PHP. That
means that if you have a free web site like GeoCities, they probably can't use
it. If you are paying for your web site osting, you will have to check with
the person that owns the server, and find out if they offer PHP. There is probably
a way to do this in Java Scripting, so that GeoCities people would be able to
access it too, but if I don't know how.
Okay, so if you've talked to your server people and made sure
that the PHP deal is all taken care of, here's what you do:
Part I
The pictures.
1. Find or create two images that you want to use for displaying
if you are online or offline. (I have this set up for ".png"s, and
that is what I would recommend using. However, if you want to use another image
format, that is fine. You will just have to make an additional change later.)
2. Save these two files to your home directory as "online.png"
and "offline.png". (Or online.gif" and "offline.gif",
or whatever.)
Part II
This part creates a program that goes to your profile and checks for the text
"I'm online now!". If it finds the text, it returns the image called
"online.png", and if it does not find the text, it returns the image
called "offline.png". (Don't worry, you don't really have to understand
it - just follow the directions.)
1. Create a new file in your home directory named "online.php".
2. Paste the following text into the file, (from the "<?"
to the "?>":
<?
// Open a connection Yahoo's servers.
$yahoohandle = fsockopen("profiles.yahoo.com", 80);
if ($yahoohandle)
{
// Send the HTTP request.
fputs($yahoohandle, "GET /YOUR YAHOO ID HERE
HTTP/1.1\nHost: profiles.yahoo.com\n\n");
// Read the resultant page and close the connection.
$page = fread($yahoohandle, 16000);
fclose($yahoohandle);
// Determine filename based on online status.
if (strstr($page, "I'm online now!"))
$filename = "online.png";
else
$filename = "offline.png";
// Read in the data for the chosen image (offline or
online).
$imagehandle = fopen ($filename, "r");
$len = filesize($filename);
$image = fread($imagehandle, $len);
fclose($imagehandle);
header("Content-type: image/png");
Header("Content-length: $len");
print($image);
}
?>
3. Change the line that in the above text that says YOUR
YAHOO ID HERE to be your yahoo id. My yahoo ID is ethernight, so
for me the line should look like this:
fputs($yahoohandle, "GET /ethernight HTTP/1.1\nHost:profiles.yahoo.com\n\n");
4. If you want to use a file format other than ".png",
you need to change every place in this document that says ".png" to
the name of your file extension, for example, ".gif". There are three
places you will need to change it. (If you are using ".png" you can
skip this part.)
a. Line 15 - where it says "online.png"
b. Line 17 - where it says "offline.png"
c. Line 25 - where it says ""Content-type: image/png"
5. Save the file. (A reminder - the name of the file should
be online.php)
Part III
Here you are going to actually change your page. You are going to add an "img
src" link that goes to the program that you just saved to get the image.
1. Find the place in your HTML code where you want the
picture to show up.
2. Add this line to your code:
<a href="http://edit.yahoo.com/config/send_webmesg?.target=YOUR
YAHOO ID HERE"><img src=online.php border=0> </a>
3. Change the text "YOUR YAHOO ID HERE" to be
your yahoo id. Again, since my Yahoo ID is ethernight, mine should look like
this:
<a href="http://edit.yahoo.com/config/send_webmesg?.target=ethernight">
<img src=online.php border=0></a>
Now just test it and make sure that everything is working okay, (on all browsers,
if you want to be a good web page programer).
Does that all make sense? If not or if you need a hand, let me know what is
unclear, and I'll try to help
Enjoy!
~Alissa
ethernight@yahoo.com
http://dusk.org/ShadesOfBlack
BEFORE you contact Alissa please [READ
THIS]
the above information is © Alissa (ethernight) 2001
it is a contribution to our site from her.... thanks :-)
|