Server-Side Presence Check in 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. These are all good things. The only real drawback is that we can't generate your code for you. Here's a quick example of how you might go about doing server-side presence in PHP.

Requires PHP ver 5, could be ported to ver 4

  $doc = new DOMDocument();
  $show = 'unavailable';
  $resources = $doc->getElementsByTagName('resource');
  if ($resources->length > 0) {
    $show = $resources->item(0)->getAttribute('show');
  if ($show == 'available' || $show == 'chat') {
    ?>You are available for chatting.<?php
  } else {
    ?>You are not available.<?php

Document URL:

©2021 Nub Games, Inc.