|
|
PresenceExamples
Examples of ways to use the PresenceAPI.
Server-Side Presence Check in PHP
(requires PHP ver 5, could be ported to ver 4)
For a Queue
<?php
$doc = new DOMDocument();
$doc->load('http://libraryh3lp.com/presence/jid/you/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
}
?> For an Individual
<?php
$doc = new DOMDocument();
$doc->load('http://libraryh3lp.com/presence/jid/you/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
}
?> -- Related --
See also PresenceApi.
Sign in to add a comment
