Stuart McCulloch AndersonStuart McCulloch Anderson Stuart McCulloch Anderson
  • Welcome to StuAnderson
    The ma’r I see of some fock, the ma’r i like my dog

    11May Creating My Custom Skype Button


    UPDATE: This page has been migrated over to NxFifteen Research Group.
    For the latest updates and support please visit http://www.nxfifteen.com/projects/skypebutton

    Amoung the many improvements I have been making to my this last week I decided I would add a Skype "Call Me" style button to the side bar. The complicated part of this arose when I found I did not really care for any of the available buttons offered by Skype, so I set about coding my own custom buttons in PHP.

    You see Skype provides a bunch of free custom buttons but did not want to be tied into the default Skype buttons images. For more Skype users I imagine that would be fine, and if you are looking for is a quick and dirty method of displaying your Skype online presence the visitors of your website then I would recommend looking at the Skype free custom buttons wizard. However if you're looking for more control over what you presence icons will look like then continue reading I will explain how I produced mine.

    The solution I found was this great script which I then a heavily modified. Basically it is a PHP application that ties into the status codes of Skype and returns a PNG image associated with the current online status of the requested user. Because the return value is the correct PNG image is possible to incorporate the script into any HTML website be it one hosted on your own server or our external for example forums.

    Like all my freeware applications and scripts you can download from here. Basically download that zip file can place a folder on your web server then just open skype.php and enter your Skype username on line 50. if you would like to change your icons all you must do is change each of the images included in the image folder maintaining the file names.

    Now all you have to do is enter the URL of skype.php into any HTML image tag for e.g.

    <img src="http://www.stuartanderson.eu.com/myapps/presence/skype.php" />
    becomes

    The grunt work of this application is performed by this function "getRemoteStatusSkype" which uses your username to Queenie Skype for numerical return value then translates it user friendly text value. The download application is formatted into an object orientated design which incorporates some more customisation and error correction, however this function will give you an idea of how I have achieved that is.

    <?php
        function getRemoteStatusSkype($skypeUserName) {
            $statusURLskype = "http://mystatus.skype.com";
            $presence_skype = Array();
            $remote_status = fopen($statusURLskype.'/'.$skypeUserName.'.num', 'r');
            if (!$remote_status) {
                $presence_skype['showas'] = 'urlerror';
            }
            while (!feof ($remote_status)) {
                $value = fgets ($remote_status, 1024);
                $value = trim($value);
                switch($value) {
                    case "0":
                        $presence_skype['showas'] = "unknown";
                        break;
                    case "1":
                        $presence_skype['showas'] = "offline";
                        break;
                    case "2":
                        $presence_skype['showas'] = "online";
                        break;
                    case "3":
                        $presence_skype['showas'] = "away";
                        break;
                    case "4":
                        $presence_skype['showas'] = "xa";
                        break;
                    case "5":
                        $presence_skype['showas'] = "dnd";
                        break;
                    case "6":
                        $presence_skype['showas'] = "forbidden";
                        break;
                    case "7":
                        $presence_skype['showas'] = "available";
                        break;
                    default:
                        $presence_skype['showas'] = "returnerror";
                        break;
                }
            }
            fclose($remote_status);
            return $presence_skype['showas'];
        }

    Update, 17th July 2010

    New Debug Ouput
    Running in debug mode

    URL: http://INSTALLURL/INSTALLDIRECTORY/
    Requested Service: skype
    skype Username: YOURUSERNAME
    Current PHP version: 5.2.4-2ubuntu5

    Your Feedback...

    "I wanted to try this but the" by Kevin Bednar (not verified) May 14, 2010 - 01:43
    Guest's picture
    I wanted to try this but the download link is not working. It returns a file not found error. Is there another URL I can try? Thanks.

    "Hey Kevin, Well that" by stuartma May 17, 2010 - 00:08
    's picture

    Hey Kevin,

    Well that annoying, lest of all cause I could have swarn I checked that link before I posted this. I've now fixed the problem at least, so you can download the zip file from the link above again.

    Visit stuartma's profile

    "Thanks Stuart, I'll download" by Kevin Bednar (not verified) May 17, 2010 - 17:18
    Guest's picture
    Thanks Stuart, I'll download and give it a spin! Kevin

    "Let me know how you get on" by stuartma May 17, 2010 - 18:55
    's picture

    Let me know how you get on

    Visit stuartma's profile

    "Tried this on this page of my" by MBB (not verified) July 17, 2010 - 05:24
    Guest's picture
    Tried this on this page of my site: http://mindbodybirths.com/index.php?option=com_content&view=article&id=4... in the first paragraph. Changed the username in the proper place and replaced my own images, then uploaded to http://mindbodybirths.com/Joomla/customskypebutton and referenced same plus /skype.php in the image source. What am I doing wrong that it's not working? Visit MBB (not verified)'s profile

    "Good afternoon MBB, From what" by stuartma July 17, 2010 - 11:54
    's picture

    Good afternoon MBB,

    From what I've been able to find from my end it looks like there might be a problem with your copy of the source code, around line 47 of the status.php file have you made anychanges to this file?

    I have updated the CustomSkypeButtons download file with a little more debugging options. For debuging this updated script will now print the full PHP version you are running. I have also included an example (Bellow the original post) of the text output by this new debug feature, incase anyone is concerned about their security.

    I wrote the script in PHP Version 5 so it is possible if you are running and older version of PHP some of the code I am using is not backward compatable (This is entirly my fault not yours!). If can you install this update I will be able to see the current PHP version number you are running and update the script to work for you quite easily!

    You can download the new zip file from this URL -> CustomSkypeButtons_Version-1.1.zip

    Visit stuartma's profile

    Stuart McCulloch Anderson

    E stuart at anderson dot eu dot comA +44 131 208 3764