Building a custom Skype-me button with status icon
a simple PHP solutionI’m not a big fan of Skype and I usually don’t use it. However, in a recent project, I was asked to add a “Skype Me” button in the contacts section of a client’s website.
I guess you all know Skype provides a bunch of free buttons and even an online wizard to build custom buttons. This works pretty good, except it only allows to use the default Skype buttons and icons and images are PNGs.
What to do then if you need to use custom-designed buttons? Or if you’re targeting IE6 and have no transparent-PNGs support? I scored 2 on 2, having both those problems.
So I decided to search for some Skype documentation and build a script myself.
Some basic information on creating custom Skype buttons and links can be found here. This explains how to code links, but still doesn’t address my problem. Then I found some more in-depth documentation on building web-services and apps interacting with Skype, that can be downloaded from here.
This way I found out that you can call a remote Skype URL, passing in your username and some parameters, to retrieve a status button, a status code or a status string.
The numeric status code is easier to use. Here’s a short list of numeric codes and their meaning:
- 0 – unknown
- 1 – offline
- 2 – online
- 3 – away
- 4 – not available
- 5 – do not disturb
- 6 – invisible
- 7 – skype me
Half of the job was done. Now I needed to link each code to a custom-designed status icon.
So that calling the PHP function with the desired username…
…returns the necessary HTML code for the icon image.
Of course I had then to go back to Photoshop and design my custom icons. I simply named the files like the status codes, where 1.jpg is the icon for offline, 2.jpg is the icon for online and so on.
I’ve tested this script using my Skype account and other accounts and seems pretty reliable. This is not the only method and I’m pretty sure this is not even the best method available, but it’s just the solution I have found to this problem and wanted to share it.
Download the source code (4k ZIP)