A PHP Tutorial for AIM Statuses

A PHP Tutorial for AIM Statuses thumbnail
PHP can detect whether an AIM user is online.

Developing in PHP allows you to create Web applications that can interact with the user and a variety of other services. For example, it is possible using PHP, potentially alongside JavaScript, to detect whether an AOL Instant Messenger user is online. AOL provides online status feedback from its servers using a single Web request.

Instructions

    • 1

      Create a PHP script in the head of your document to determine the AIM username you want to check the online status of. Create a Web request and optionally online and offline images:

      <?php
      $username = ...
      $online_image = "http://www.mydomain.com/images/online.gif";
      $offline_image = "http://www.mydomain.com/images/online.gif";
      $offline_redirect = "http://doesnotexist.404error.com";

      $my_request = "http://big.oscar.aol.com/$username?on_url=$online_image&off_url=$offline_image";
      $my_other_request = "http://big.oscar.aol.com/$username?on_url=$online_image&off_url=$offline_redirect";
      ?>

    • 2

      Create an HTML "<img>" tag in the body of your PHP document to initiate the AIM Web request and load the appropriate image:

      <div id="AIM_status">
      <?php
      print "<img id=status_1 url=$my_request>";
      ?>
      </div>

    • 3

      Create an alternate "<img>" tag with corresponding JavaScript code to dynamically create content depending on whether the AIM status request redirects to a valid URL or not:

      <script type="text/javascript">
      var image_status = function handle_status(state){
      if(status){
      //Do something if user is online
      } else{
      //Do something if user is offline
      }
      }
      </script>

      <div id="AIM_status">
      <?php
      print "<img id=status_1 url=$my__other_request onload='handle_status(1);' onerror='handle_status(0);'>";
      ?>
      </div>

Related Searches

References

  • Photo Credit Hemera Technologies/Photos.com/Getty Images

Related Ads

View Mobile Site