• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Any Skype experts out there?

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Any Skype experts out there?

    I'm having a footer around with Skype at the moment, as I intend to use it going forward to satisfy requests for interviews and meetings where distance is an issue.

    To this end, I've placed a button on my technical blog that enables my contacts to contact me this way, and also shows my online status. That's fairly simple: it just uses a simple button generator provided by Skype to achieve the result shown:


    The button itself uses some JavaScript hosted by Skype in conjunction with some simple HTML markup to achieve the effect, and to provide meaningful functionality for the button. (e.g., if you're online, and you're an approved contact, clicking it will initiate a call, etc).

    So far, so good. However, the results are a bit crap. For one thing, the button's background is white rather than transparent, even though the images themselves are PNGs (which should have made making the background transparent easy). I also thought it'd be a fun effect if the photo shown changed to reflect my current status: empty chair for "Away", head stuck behind laptop for "Do Not Disturb", etc. That's what I'm working on now.

    There's a more advanced button generator on the Skype site that appears to have been intended to allow transparent backgrounds to be generated, but it doesn't appear to have been finished. You can't actually therefore use it to achieve a button with a transparent background (nor obviously the other effects mentioned).

    _______________________________________

    So far, I've used this article and this one too, and have been able to get a prototype of the full functionality I intend working locally. However, as a key part of the process involves reading your status from Skype, which in essence involves being able to read a text file with a simple numeric code indicating your current status, you do also need to use Skype's own JavaScript to make the process work. The reason being that, for security reasons, you can't make cross-domain AJAX calls using JavaScript, so even something like reading a simple text file hosted on another domain is out. Otherwise I'd have simply used jQuery's "get" method to read the status text file hosted by Skype to achieve the desired effect.

    So, at least it's working. However, when I looked through Skype's js file, it makes clear that it's a legacy script, and that a script called "detection.js" should be used instead in new developments:

    Code:
    /*
     * This is the legacy public Skype detection file converted to use new Flash
     * based detection library. It is mainly used for old Skype web buttons, though
     * some 3rd party sites have made use of it as well. This file tries to expose
     * the same API as previous implementation to not break 3rd party sites.
     *
     * Please use detection.js (SkypeDetection object) based library instead of
     * this in all new site developments.
     */
    Despite having had a Google around, I can't find that script. My question is, do any of you have any experience of using detection.js, and where I can find it?

    #2
    I'm no expert, but I found this:
    How to get skype status as number or text? mystatus.skype.com doesnt work - Stack Overflow

    If you can get your status as a number or text then you can provide your own button !

    Comment


      #3
      Originally posted by Platypus View Post
      I'm no expert, but I found this:
      How to get skype status as number or text? mystatus.skype.com doesnt work - Stack Overflow

      If you can get your status as a number or text then you can provide your own button !
      Thanks, Platty.

      I went down that route last night, unfortunately, and found it didn't work. Although you can just put that URL into any browser (replacing the Skype name where appropriate), and see a person's status (provided they've enabled that), unfortunately it doesn't work via JavaScript. (Which is the only way I can do it, since as it's my blog I unfortunately only have access to Clientside code).

      The JavaScript I tried to access that status from was:

      Code:
              jQuery.get('http://mystatus.skype.com/mySkypeName.txt', function (data) {
                  alert(data);
              });
      Which just fails without explanation. I then tried to hard-code the XMLHttpRequest myself (which is probably what jQuery is doing in the above code), in the following way:

      Code:
              var xmlhttp;
              if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
                  xmlhttp = new XMLHttpRequest();
              } else {// code for IE6, IE5
                  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
              }
      
              xmlhttp.onreadystatechange = function () {
                  if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                      var str = xmlhttp.responseText.split(".");
                      //split the string by dot
      
                      for (var i = 0; i < str.length; i++)//read the string
                          alert(str[i]);
                  }
              }
              xmlhttp.open("GET", "http://mystatus.skype.com/mySkypeName.txt", true);
              xmlhttp.send();
      Which still fails, but at least tells you why (because cross-domain 'get' requests aren't supported for security reasons).

      There's also all sorts of other useful gubbins that Skype's own JavaScript does, like guiding the user on how to install Skype if they don't have it, and it's useful to have that functionality for free by using their script. I just wish I could be sure their script wont stop being supported.

      Comment


        #4
        LOL cracked it! If you have somewhere you can host images and some PHP (or ASP I suppose)

        Change the code in your blog to be:
        Code:
        <script type="text/javascript" src="http://download.skype.com/share/skypebuttons/js/skypeCheck.js"></script>
        <a href="skype:username?call"><img src="http://www.mywebsite.com/html/skypestatus.php" style="border: none;" width="150" height="60" alt="My status" /></a>
        Then on mywebsite I created the new page:

        PHP Code:
        <?php

        $skypestatus 
        file_get_contents('http://mystatus.skype.com/username.txt');

        if (
        $skypestatus == "Do Not Disturb") {
            
        $skypeimage "skype-dnd.png";
        }
        elseif (
        $skypestatus == "Online") {
            
        $skypeimage "skype-online.png";
        }
        elseif (
        $skypestatus == "Away") {
            
        $skypeimage "skype-away.png";
        }
        else {
            
        $skypeimage "skype-offline.png";
        }

        header('Content-type: image/png');
        readfile("http://www.mywebsite.com/images/$skypeimage");
        ?>
        In the images directory I have my own copies of the Skype buttons but with the white background converted to transparent.

        And it works

        EDIT:

        Last edited by Platypus; 24 August 2012, 15:58.

        Comment


          #5
          Originally posted by Platypus View Post
          LOL cracked it! If you have somewhere you can host images and some PHP (or ASP I suppose)...
          Unfortunately not. For the reasons mentioned above, only a solution that works entirely on the clientside will do in this case - I don't have access to the server that blogspot runs on, and even if I host a solution that relies on serverside code elsewhere (there are a few such solutions mentioned above), I'd unfortunately be unable to access that solution in the way I need to owing to cross-domain limitations in calls made from JavaScript (or any other clientside code).

          It's important to be able to access any status calculated serverside, and not just serve an image, because a lot of the other functionality mentioned (e.g., to determine the appropriate functionality to be associated with the button) is driven by the code actually knowing the status, as opposed to just serving a desired alternative image.

          Thanks for the thought, though.

          I've even tried using JavaScript to compare the images served up by Skype with locally-stored versions to determine the status. But even that fails owing to this X-domain issue. E.g.: the image below indicates my status (also shown on the left), but just try accessing that image through code and it's as impossible as accessing the txt file mentioned earlier:

          Comment


            #6
            There appears to be something in this article here that works. It utilises this jQuery override script. I haven't finished mucking around with it yet, but it appears to override jQuery's "ajax" method, to make it a JSON request, thereby effectively overridding the cross-site scripting limitaton (since the whole content of the page is simply scraped and returned via JSON as a string).

            When you reference the above script, the

            Code:
                    jQuery.get('http://mystatus.skype.com/mySkypeName.txt', function (data) {
                        alert(data);
                    });
            script I mentioned earier starts to work, since it's now using the modified jQuery ajax method that is allowed.

            Comment


              #7
              Do you have another server you can host some code on?

              Then you could set the image source to a file on your server, and do the logic to serve the appropriate content there.

              Comment


                #8
                Originally posted by Platypus
                If you have somewhere you can host images and some PHP ...
                Originally posted by Gentile View Post
                Unfortunately not
                Originally posted by mudskipper View Post
                Do you have another server you can host some code on?

                Comment


                  #9
                  Originally posted by mudskipper View Post
                  Do you have another server you can host some code on?

                  Then you could set the image source to a file on your server, and do the logic to serve the appropriate content there.
                  Thanks ms, but see the post direct above yours for the reasons why that approach unfortunately isn't suitable in this particular instance: it's not just appropriate content that needs to be served, but clientside logic that must be able to access the actual status in order to be able to decide what to do. i.e., the button needs to be able to do different things depending on the context ("I'm online" = "initiate a call", "I'm away" = "Show an alert that indicates I'm not available", "User doesn't have Skype installed" = "Show them how they can get Skype", etc). That kind of program flow in the clientside code requires knowing the actual status, not just having an appropriate image served.

                  I've got something kind-of-working now, though it's hacky as hell. It relies on tricking JavaScript into thinking it's making a JSON request, which gets around the cross-domain scripting limitation. It then uses Regex to extract relevant data indicating the online status from the 'JSON object' (read: 'predictably-formatted html rendered as a string') that it gets back. It feels a bit Heath Robinson, but at least it works.

                  I'll post the finished JavaScript once I've tidied it up a bit, in case anyone else Googles for the same problem at some point!

                  Thanks again all for your suggestions and advice.

                  Comment


                    #10
                    Originally posted by Platypus View Post
                    - I've done that myself often enough!

                    I do appreciate all of the advice received, though. Thanks again for your suggestions.

                    Comment

                    Working...
                    X