I just wanted to post this because I searched forever & couldn't find anything. Maybe it will help someone else out or someone has something better.. Might not be the best solution, I have yet to see anything else, but it works.. With this you're able to use your own custom buttons, text, run something, etc. by determining the size of Skypes online/offline user buttons

$button = "http://mystatus.skype.com/smallicon/username.png";
$status = "status.png";
copy($button, $status);
//online = 428  offline = 376
if (filesize($status) > 400) {
	//online
} else {
	//offline
}
    7 days later

    What about...

    function getSkypeStatus($username) {
    	$data = file_get_contents('http://mystatus.skype.com/' . urlencode($username) . '.xml');
    
    return strpos($data, '<presence xml:lang="en">Offline</presence>') ? 'Offline' : 'Online';
    // Or replace the two strings with integer 1 or 0 (or boolean TRUE or FALSE)
    // ... whatever you want
    }

    or, slightly more versatile, ...

    function getSkypeStatus($username) {
    	$data = file_get_contents('http://mystatus.skype.com/' . urlencode($username) . '.xml');
    	preg_match('@<presence xml:lang="en">(.*?)</presence>@i', $data, $match);
    
    return isset($match[1]) ? $match[1] : 'Error retrieving status';
    }
      a month later
      bradgrafelman;10895248 wrote:

      What about...

      function getSkypeStatus($username) {
      	$data = file_get_contents('http://mystatus.skype.com/' . urlencode($username) . '.xml');
      
      return strpos($data, '<presence xml:lang="en">Offline</presence>') ? 'Offline' : 'Online';
      // Or replace the two strings with integer 1 or 0 (or boolean TRUE or FALSE)
      // ... whatever you want
      }

      or, slightly more versatile, ...

      function getSkypeStatus($username) {
      	$data = file_get_contents('http://mystatus.skype.com/' . urlencode($username) . '.xml');
      	preg_match('@<presence xml:lang="en">(.*?)</presence>@i', $data, $match);
      
      return isset($match[1]) ? $match[1] : 'Error retrieving status';
      }

      sooo much better than that waste of time I was doing. thank you sir.

      Although for reference i think its better to search for an "online" and else the "offline" instead of how you have it as, if the status is Idle, Away, etc. the returned status would be "online" - which is usually what you're not when you are Idle, Away, etc.

        a year later

        I was looking at my website again and thought I need to have only the skype online image visible.

        I could not get the above code to work😕 or the code in the other link I posted; so I made something that echoed the http://mystatus.skype.com/user.name.here.txt in the image name to display the image url I wanted from my server. :-)

        Code, image files, and instructions are here: http://www.abcpchelp.com/phpSkypeButton-CustomButtons.zip

          4 years later
          mvandiermen;10953854 wrote:

          you can also use the to create any image you want for each skype status, you just need to edit the images in the folder

          Dear Sir,

          I've tried this but it is not working. It is giving me the following result where it is suppose to show the status image from skype_img directory.

          [ATTACH]5029[/ATTACH]

          It look like

           {print $line;}?>

          couldn't the status/image name exactly. Can you help me sort out this?

          111.png
            6 days later
            8 days later
            a year later
            sherazi21st;11038079 wrote:

            Dear Sir,

            I've tried this but it is not working. It is giving me the following result where it is suppose to show the status image from skype_img directory.

            [ATTACH]5029[/ATTACH]

            It look like

             {print $line;}?>

            couldn't the status/image name exactly. Can you help me sort out this?

            Some time in 2014 Skype changed their button system and so current script is not working. If I check out the new system I could make one but do not have time right now.

              2 months later
              bradgrafelman;10895248 wrote:

              What about...

              function getSkypeStatus($username) {
              	$data = file_get_contents('http://mystatus.skype.com/' . urlencode($username) . '.xml');
              
              return strpos($data, '<presence xml:lang="en">Offline</presence>') ? 'Offline' : 'Online';
              // Or replace the two strings with integer 1 or 0 (or boolean TRUE or FALSE)
              // ... whatever you want
              }

              or, slightly more versatile, ...

              function getSkypeStatus($username) {
              	$data = file_get_contents('http://mystatus.skype.com/' . urlencode($username) . '.xml');
              	preg_match('@<presence xml:lang="en">(.*?)</presence>@i', $data, $match);
              
              return isset($match[1]) ? $match[1] : 'Error retrieving status';
              }

              Please for the love of whatever deity or system you ascribe value @file_get_contents. Also you only need to test for '>Offline</presence>' preg is using a machine digger to pot a plant, it only need to be as versatile.

              I would also advise taking in two POST arguments rather than one GET as you could have value, checksum to stop third-parties leeching off your site and lastly curl would be a slight improvement still because you could also detect HTTP status code in the event skype was too busy to respond (happened to me throughout 2012, ended up setting up an a href with "skype:username" in it during office hours

                cyberlew15;11046235 wrote:

                Please ... @file_get_contents

                Why? Apart from wanting to slow things down and to suppress logging an error message that would tell you that something is wrong?

                  Weedpacket;11046241 wrote:

                  Why? Apart from wanting to slow things down and to suppress logging an error message that would tell you that something is wrong?

                  Honestly it's because it looks terrible to have notices, warnings etc popping up on websites from a cosmetic point of view; coupled with the fact that file_get_contents was what was being pushed in all previous posts, it's the simplest remittance of the issue. Also turning down the reporting of errors (the only other way to fix using file_get_contents, does not affect the toll each error presents, which is what causes the slowdown regardless of suppression, it's not the suppression that causes the issue, just the error.

                  If it makes you happier they can manually ob_start before the call, then ob_flush to get rid of the message, which also allows them to log, or to override error handler... I think that these are overkill, or they could adjust their error_reporting, which is basically plastering over the cracks of unstable code (as is using @ for suppression, but it at least signifies knowledge that file_get_contents is capable of failing to get files, so you can focus on remitting no content)

                  All the best 😃

                    cyberlew15 wrote:

                    Honestly it's because it looks terrible to have notices, warnings etc popping up on websites from a cosmetic point of view; coupled with the fact that file_get_contents was what was being pushed in all previous posts, it's the simplest remittance of the issue.

                    That should be handled by logging instead of displaying errors in production.

                    cyberlew15 wrote:

                    Also turning down the reporting of errors (the only other way to fix using file_get_contents, does not affect the toll each error presents, which is what causes the slowdown regardless of suppression, it's not the suppression that causes the issue, just the error.

                    Turning down the reporting of errors is not the only other way to "fix" using file_get_contents, and it is not even the correct approach: rather, one should check for the possible errors in the first place, e.g., by calling file_exists prior to calling file_get_contents.

                    cyberlew15 wrote:

                    If it makes you happier they can manually ob_start before the call, then ob_flush to get rid of the message, which also allows them to log, or to override error handler... I think that these are overkill, or they could adjust their error_reporting, which is basically plastering over the cracks of unstable code (as is using @ for suppression

                    That is not overkill; that is being silly. file_get_contents is not "unstable code".

                    cyberlew15 wrote:

                    it at least signifies knowledge that file_get_contents is capable of failing to get files, so you can focus on remitting no content)

                    The fact that file_get_contents is capable of failing to get files should be handled by checking the return value for equivalence with false prior to using the contents retrieved.

                    EDIT:
                    Oh, but I see that the file name is actually some URL, in which case file_exists would not be applicable. Nonetheless, the "cosmetic point of view" would not have mattered: rather, one would have seen the errors in the log in the event that the URL was somehow incorrect or inaccessible: the function call would still have been essentially fine if its return value had been checked.

                      That should be handled by logging instead of displaying errors in production.

                      And I mentioned this as well as two methods for logging + one opportunity to use what we know to test...

                      Turning down the reporting of errors is not the only other way to "fix" using file_get_contents, and it is not even the correct approach: rather, one should check for the possible errors in the first place, e.g., by calling file_exists prior to calling file_get_contents.

                      Agreed, if you go on to read before quoting you will see some other idea's but as you have mentioned in your edit file_exists URL support is not production standard

                      That is not overkill; that is being silly. file_get_contents is not "unstable code".

                      Given the context of file_get_contents for a URL it is incredibly unstable compared to CURL and more network or http specific functions and libraries

                      The fact that file_get_contents is capable of failing to get files should be handled by checking the return value for equivalence with false prior to using the contents retrieved.

                      As mentioned

                      so you can focus on remitting no content

                      Reading through the thread it seems several paragraphs of my initial response are missing, not sure whats up there PHPBuilder, but in them I distinctly recall mentioning using CURL as it allows you to check HTTP status codes (much more verbose than file_exists), so in short despite some differences of opinion, I don't think anyone can say file_get_contents should probably not be used for this, but if it is, you should prefix @ for suppress errors and check length...

                        cyberlew15 wrote:

                        Given the context of file_get_contents for a URL it is incredibly unstable compared to CURL and more network or http specific functions and

                        The Internet itself is "unstable". I don't see it as a problem with file_get_contents, as limited as it may be for this purpose.

                        cyberlew15 wrote:

                        Reading through the thread it seems several paragraphs of my initial response are missing, not sure whats up there PHPBuilder, but in them I distinctly recall mentioning using CURL as it allows you to check HTTP status codes (much more verbose than file_exists)

                        You did mention cURL at the end of your post #12. That's a very different story though: cURL would be an appropriate, even preferred, alternative to file_get_contents considering that a URL is involved.

                          Wow... 😕

                          laserlight;11046255 wrote:

                          The Internet itself is "unstable". I don't see it as a problem with file_get_contents, as limited as it may be for this purpose.

                          You did mention cURL at the end of your post #12. That's a very different story though: cURL would be an appropriate, even preferred, alternative to file_get_contents considering that a URL is involved.

                          So to recap after all this "noise", topped with the nonsense that 'The Internet itself is "unstable"', we learned that file_get_contents is a limited solution without the capability to fully handle the HTTP resources, and there is a more suitable, robust solution in cURL (pedantic as hell btw, but previously mentioned regardless of case-sensitivity )...

                          In the interests of helping OP and not just being noisy on the thread or forums, I feel that perhaps reading previous posts might help, as we have not really covered any new ground since you and Weedpacket chimed in, which is sad for OP and for readability of this post. In future if you can PM me any half-read responses instead, it would be appreciated I am sure by all, but definitely by me

                          • Not using @ may cause undesirable effects

                          • You could also set error handler, use output buffering, or (best case) use cURL to talk to any HTTP resource

                          • It's a good idea to log any errors / issues

                          • Setting up an anchor with href "skype:username", can be used to initiate a skype call in systems supporting skype: streams

                          • arguments break out on the internet... 😉

                            cyberlew15 wrote:

                            topped with the nonsense that 'The Internet itself is "unstable"'

                            Sorry, but that is no more nonsense that your claim that "given the context of file_get_contents for a URL it is incredibly unstable compared to CURL and more network or http specific functions and libraries". Perhaps the phrase that you were looking for is "not as robust" (i.e., in terms of error handling and options relevant to networks), which you did use in the end 😉

                            One thing that you did leave out in your summary: remember to check the return value of functions that can fail with a value that indicates failure. (So much for "have not really covered any new ground" and "half-read responses", especially considering that I obviously read your other idea since I referred to it.)

                              cyberlew15;11046253 wrote:

                              you should prefix @ for suppress errors and check length...

                              I'm going to have to disagree with you completely. The @ prefix should never be used and the code should instead be designed to handle any errors conditions that may arise.