} function getPresence($payloads, $jaxl) { foreach ($payloads as $payload) { // print_r($payload); } } function postSubscriptionRequest($payload, $jaxl) { $jaxl->log("Subscription request sent to " . $payload['from']); } function postSubscriptionAccept($payload, $jaxl) { $jaxl->log("Subscription accepted by " . $payload['from']); } function getId($payload, $jaxl) { return $payload; } } // Add callbacks on various event handlers $echobot = new echobot(); $jaxl->addPlugin('jaxl_post_auth', array($echobot, 'postAuth')); $jaxl->addPlugin('jaxl_get_message', array($echobot, 'getMessage')); $jaxl->addPlugin('jaxl_get_presence', array($echobot, 'getPresence')); $jaxl->addPlugin('jaxl_post_roster_update', array($echobot, 'postRosterUpdate')); $jaxl->addPlugin('jaxl_post_subscription_request', array($echobot, 'postSubscriptionRequest')); $jaxl->addPlugin('jaxl_post_subscription_accept', array($echobot, 'postSubscriptionAccept')); $jaxl->addPlugin('jaxl_get_id', array($echobot, 'getId')); // Fire start Jaxl core $jaxl->startCore("stream");
public static function postAuthFailure($payload, $jaxl) { $response = array('jaxl' => 'authFailed'); $jaxl->JAXL0206('out', $response); } public static function postCurlErr($payload, $jaxl) { if ($_REQUEST['jaxl'] == 'disconnect') { self::postDisconnect($payload, $jaxl); } else { $jaxl->JAXL0206('out', array('jaxl' => 'curlError', 'code' => $payload['errno'], 'msg' => $payload['errmsg'])); } } } // Add callbacks on various event handlers $jaxl->addPlugin('jaxl_post_auth_failure', array('boshchat', 'postAuthFailure')); $jaxl->addPlugin('jaxl_post_auth', array('boshchat', 'postAuth')); $jaxl->addPlugin('jaxl_post_disconnect', array('boshchat', 'postDisconnect')); $jaxl->addPlugin('jaxl_get_empty_body', array('boshchat', 'postEmptyBody')); $jaxl->addPlugin('jaxl_get_bosh_curl_error', array('boshchat', 'postCurlErr')); $jaxl->addPlugin('jaxl_get_message', array('boshchat', 'getMessage')); $jaxl->addPlugin('jaxl_get_presence', array('boshchat', 'getPresence')); $jaxl->addPlugin('jaxl_post_roster_update', array('boshchat', 'postRosterUpdate')); // Handle incoming bosh request switch ($_REQUEST['jaxl']) { case 'connect': $jaxl->user = $_POST['user']; $jaxl->pass = $_POST['pass']; $jaxl->startCore('bosh'); break; case 'disconnect':
<?php /** * Sample command line bot for sending a message * Usage: cd /path/to/jaxl * Edit username/password below * Run from command line: /path/to/php sendMessage.php "*****@*****.**" "Your message" * View jaxl.log for detail * * Read More: http://jaxl.net/examples/sendMessage.php */ // Initialize Jaxl Library require_once '../core/jaxl.class.php'; // Values passed to the constructor can also be defined as constants // List of constants can be found inside "../../env/jaxl.ini" // Note: Values passed to the constructor always overwrite defined constants $jaxl = new JAXL(array('user' => 'username', 'pass' => 'password', 'host' => 'talk.google.com', 'domain' => 'gmail.com', 'authType' => 'DIGEST-MD5', 'logLevel' => 5)); // Post successful auth send desired message function postAuth($payload, $jaxl) { global $argv; $jaxl->sendMessage($argv[1], $argv[2]); $jaxl->shutdown(); } // Register callback on required hooks $jaxl->addPlugin('jaxl_post_auth', 'postAuth'); // Fire start Jaxl core $jaxl->startCore("stream");
* View jaxl.log for detail * * Read More: http://jaxl.net/examples/sendMessage.php */ // Initialize Jaxl Library require_once '../core/jaxl.class.php'; require_once '../core/func.php'; // Values passed to the constructor can also be defined as constants // List of constants can be found inside "../../env/jaxl.ini" // Note: Values passed to the constructor always overwrite defined constants $jaxl = new JAXL(array('user' => 'user3', 'pass' => 'password', 'host' => SERVER, 'domain' => SERVER, 'authType' => 'PLAIN', 'logLevel' => 4)); // Post successful auth send desired message function postAuth($payload, $jaxl) { global $argv; $jaxl->sendMessage($argv[1], $argv[2]); $jaxl->shutdown(); } // Register callback on required hooks function thisistestfunction($payload, $jaxl) { pr($payload); } function testx($payload, $jaxl) { $jaxl->requires('JAXL0060'); $jaxl->JAXL0060('createNode', 'pubsub.64.22.114.70', 'user3@64.22.114.70', 'test1223', 'thisistestfunction'); echo 'hey'; } $jaxl->addPlugin('jaxl_post_auth', 'testx'); $jaxl->startCore("stream");
function postAuth($payload, $xmpp) { $xmpp->JAXL0054('getVCard', false, $xmpp->jid, 'handleVCard'); } function handleVCard($payload, $xmpp) { echo "<form action='' method=''>"; echo "<img src='data:" . $payload['vCardPhotoType'] . ";base64," . $payload['vCardPhotoBinVal'] . "' alt='" . $payload['vCardFN'] . "' title='" . $payload['vCardFN'] . "'/>"; echo "<p><b>Nickname:</b>" . $payload['vCardNickname'] . "</p>"; echo "<p><b>Url:</b>" . $payload['vCardUrl'] . "</p>"; echo "<p><b>BDay:</b>" . $payload['vCardBDay'] . "</p>"; echo "<p><b>OrgName:</b>" . $payload['vCardOrgName'] . "</p>"; echo "<p><b>OrgUnit:</b>" . $payload['vCardOrgUnit'] . "</p>"; echo "<p><b>Title:</b>" . $payload['vCardTitle'] . "</p>"; echo "<p><b>Role:</b>" . $payload['vCardRole'] . "</p>"; echo "<p><b>Desc:</b>" . $payload['vCardDesc'] . "</p>"; echo "<input type='button' name='submit' value='Submit'/>"; echo "</form>"; $xmpp->shutdown(); } function postAuthFailure($payload, $xmpp) { echo "OOPS! Auth failed"; } // Register callbacks for required events $xmpp->addPlugin('jaxl_post_connect', 'postConnect'); $xmpp->addPlugin('jaxl_get_auth_mech', 'doAuth'); $xmpp->addPlugin('jaxl_post_auth', 'postAuth'); $xmpp->addPlugin('jaxl_post_auth_failure', 'postAuthFailure'); // Fire start JAXL Core $xmpp->startCore();
* * Read more: http://jaxl.net/examples/componentbot.php */ // Initialize Jaxl Library require_once '../core/jaxl.class.php'; $jaxl = new JAXL(array('port' => 5559, 'compHost' => 'component.localhost', 'compPass' => 'secret', 'logLevel' => 4)); // 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(); $jaxl->addPlugin('jaxl_post_handshake', array($componentbot, 'postAuth')); $jaxl->addPlugin('jaxl_get_message', array($componentbot, 'getMessage')); // Fire start Jaxl core $jaxl->startCore("component");
} return $payloads; } public static function postEmptyBody($body, $jaxl) { $response = array('jaxl' => 'pinged'); $jaxl->JAXL0206('out', $response); } public static function postAuthFailure($payload, $jaxl) { $response = array('jaxl' => 'authFailed'); $jaxl->JAXL0206('out', $response); } } // Add callbacks on various event handlers $jaxl->addPlugin('jaxl_post_auth_failure', array('boshMUChat', 'postAuthFailure')); $jaxl->addPlugin('jaxl_post_auth', array('boshMUChat', 'postAuth')); $jaxl->addPlugin('jaxl_post_disconnect', array('boshMUChat', 'postDisconnect')); $jaxl->addPlugin('jaxl_get_empty_body', array('boshMUChat', 'postEmptyBody')); $jaxl->addPlugin('jaxl_get_message', array('boshMUChat', 'getMessage')); $jaxl->addPlugin('jaxl_get_presence', array('boshMUChat', 'getPresence')); // Handle incoming bosh request switch ($_REQUEST['jaxl']) { case 'connect': $jaxl->user = $_POST['user']; $jaxl->pass = $_POST['pass']; $jaxl->startCore('bosh'); break; case 'disconnect': $jaxl->JAXL0206('endStream'); break;