* Pre-fetched data can later be htmlized and displayed on the webpage * * Usage: * ------ * 1) Put this file under your web folder * 2) Edit user/pass/domain/host below for your account * 3) Hit this file in your browser * * View jaxl.log for detail */ // include JAXL core require_once '/usr/share/php/jaxl/core/jaxl.class.php'; // initialize JAXL instance $xmpp = new JAXL(array('user' => '', 'pass' => '', 'domain' => 'localhost', 'host' => 'localhost', 'boshHost' => 'localhost', 'boshPort' => 5280, 'boshSuffix' => 'http-bind', 'boshOut' => false, 'logLevel' => 5)); // Include required XEP's $xmpp->requires(array('JAXL0054', 'JAXL0206')); function doAuth($mechanism, $xmpp) { $xmpp->auth('DIGEST-MD5'); } function postAuth($payload, $xmpp) { $xmpp->JAXL0054('getVCard', false, $xmpp->jid, 'handleVCard'); } function handleVCard($payload, $xmpp) { echo "<b>Successfully fetched VCard</b><br/>"; print_r($payload); $xmpp->JAXL0206('endStream'); } function postDisconnect($payload, $xmpp)
* Run this app file from the browser e.g. http://path/to/jaxl/app/boshchat.php * View /var/log/jaxl.log for debug info * * Read more: http://jaxl.net/example/boshchat.php */ // Ajax poll url define('BOSHCHAT_POLL_URL', $_SERVER['PHP_SELF']); if (isset($_REQUEST['jaxl'])) { // Valid bosh request // Initialize Jaxl Library require_once '/usr/share/php/jaxl/core/jaxl.class.php'; $jaxl = new JAXL(array('domain' => 'localhost', 'port' => 5222, 'boshHost' => 'localhost', 'authType' => 'DIGEST-MD5', 'logLevel' => 4)); // Admin jid who will receive all messages sent using this application ui define('BOSHCHAT_ADMIN_JID', 'admin@' . $jaxl->domain); // Include required XEP's $jaxl->requires(array('JAXL0115', 'JAXL0085', 'JAXL0092', 'JAXL0203', 'JAXL0202', 'JAXL0206')); // Sample Bosh chat application class class boshchat { public static function postAuth($payload, $jaxl) { $response = array('jaxl' => 'connected', 'jid' => $jaxl->jid); $jaxl->JAXL0206('out', $response); } public static function postRosterUpdate($payload, $jaxl) { $response = array('jaxl' => 'rosterList', 'roster' => $jaxl->roster); $jaxl->JAXL0206('out', $response); } public static function postDisconnect($payload, $jaxl) {
* Usage: * ------ * 1) Put this file under your web folder * 2) Edit user/pass/domain/host below for your account * 3) Hit this file in your browser * * View jaxl.log for detail */ // include JAXL core require_once '/usr/share/php/jaxl/core/jaxl.class.php'; // initialize JAXL instance $xmpp = new JAXL(array('user' => '', 'pass' => '', 'domain' => 'localhost', 'host' => 'localhost', 'logLevel' => 5)); // Force CLI mode since this app runs from browser but we don't intend to use BOSH or Ajax $xmpp->mode = "cli"; // Demo requires VCard XEP $xmpp->requires('JAXL0054'); function postConnect($payload, $xmpp) { $xmpp->startStream(); } function doAuth($mechanism, $xmpp) { $xmpp->auth('DIGEST-MD5'); } function postAuth($payload, $xmpp) { $xmpp->JAXL0054('getVCard', false, $xmpp->jid, 'handleVCard'); } function handleVCard($payload, $xmpp) { echo "<b>Successfully fetched VCard</b><br/>";
<?php /* * Sample command line XMPP component bot using Jaxl library * Usage: php componentbot.php * Read more: http://bit.ly/aGpYf8 */ // Initialize Jaxl Library require_once '../core/jaxl.class.php'; $jaxl = new JAXL(array('port' => 5559, 'compHost' => 'component.localhost', 'compPass' => '', 'logLevel' => 5)); // Include required XEP's $jaxl->requires('JAXL0114'); // Jabber Component Protocol // Sample Component class class componentbot { function postAuth($payload, $jaxl) { $jaxl->log("Component handshake completed ..."); } function getMessage($payloads, $jaxl) { foreach ($payloads as $payload) { if (strlen($payload['body']) > 0) { $jaxl->sendMessage($payload['from'], $payload['body'], $payload['to']); } } } } // Add callbacks on various event handlers $componentbot = new componentbot();
* Usage: Copy this application file (along with /path/to/jaxl/env/jaxl.js) into your web folder. * Edit "BOSHCHAT_POLL_URL" below to suit your environment. * Run this app file from the browser. * Read more: http://bit.ly/aMozMy */ // Ajax poll url define('BOSHCHAT_POLL_URL', 'http://localhost/boshMUChat.php'); // Admin jid who will receive all messages sent using this application ui define('BOSHCHAT_ROOM_JID', '*****@*****.**'); if (isset($_REQUEST['jaxl'])) { // Valid bosh request // Initialize Jaxl Library require_once '/usr/share/php/jaxl/core/jaxl.class.php'; $jaxl = new JAXL(array('host' => 'localhost', 'domain' => 'localhost', 'port' => 5222, 'boshHost' => 'localhost', 'authType' => 'PLAIN', 'logLevel' => 5)); // Include required XEP's $jaxl->requires(array('JAXL0115', 'JAXL0092', 'JAXL0203', 'JAXL0202', 'JAXL0206', 'JAXL0045'), $jaxl); // Sample Bosh MUC chat room application class class boshMUChat { public static function postAuth($payload, $jaxl) { list($nick, $domain, $res) = JAXLUtil::splitJid($jaxl->jid); $jaxl->JAXL0045('joinRoom', $jaxl->jid, BOSHCHAT_ROOM_JID . '/' . $nick, 0, 'seconds'); $response = array('jaxl' => 'connected', 'jid' => $jaxl->jid); $jaxl->JAXL0206('out', $response); } public static function postDisconnect($payload, $jaxl) { $response = array('jaxl' => 'disconnected'); $jaxl->JAXL0206('out', $response); }