Server-side PHP

There are a couple of reasons you might want to do server-side presence checks. It lets you avoid having to deal with any library compatibility issues, it improves your page load time by not requiring the users to download the client-side presence API code, and it lets you avoid that little flash of "requires javascript" or "we're offline" before your true presence is displayed. Here's a quick example of how you might go about doing server-side presence in PHP.

Note: Requires PHP ver 5, could be ported to ver 4.

<?php
   $doc = new DOMDocument();
   $doc->load('https://libraryh3lp.com/presence/jid/{name}/chat.libraryh3lp.com/xml');
   $show = 'unavailable';
   $resources = $doc->getElementsByTagName('resource');
   if ($resources->length > 0) {
     $show = $resources->item(0)->getAttribute('show');
   }
   if ($show == 'available') {
     ?>You are available for chatting.<?php
   } else {
     ?>You are not available.<?php
   }
?>