send message using jaxl and file transfer

130 views
Skip to first unread message

divyesh baldaniya

unread,
Jul 20, 2013, 6:09:18 AM7/20/13
to ja...@googlegroups.com
hi,
i use jaxl 3 x in localhost using opnfire server.
openfire work fine and also xmpphp working fine.

i need few instruction for send message using jaxl 3 x.
download all file & put in localhost and add all setttig in jaxl.ini file and also add settting when i use file.

but when i run file in browser it display nothing or message not send.
i use ../app/echobot.php this file.
so plz help me for send message in jaxl...

file contain===============
    /**
     * Sample command line echobot client using Jaxl library
     * Usage: cd /path/to/jaxl/app
     *           Edit passed config array to Jaxl constructor below to suit your environment
     *           Run from command line as: /path/to/php componentbot.php
     *           View /var/log/jaxl.log for debug info
     *
     * Read More: http://jaxl.net/examples/echobot.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'=>'admin username',
            'pass'=>'admin password',
            'host'=>'localhost ip',
            'domain'=>'localhost ip',
            'authType'=>'PLAIN',
            'autoSubscribe'=>true,
            'pingInterval'=>60,
            'logLevel'=>4,
        ));
   
    // Include required XEP's
    $jaxl->requires(array(
        'JAXL0115', // Entity Capabilities
        'JAXL0092', // Software Version
        'JAXL0199', // XMPP Ping
        'JAXL0203', // Delayed Delivery
        'JAXL0202'  // Entity Time
    ));

    // Sample Echobot class
    class echobot {   
        function postAuth($payload, $jaxl) {
            $jaxl->discoItems($jaxl->domain, array($this, 'handleDiscoItems'));
            $jaxl->getRosterList();
        }

        function handleDiscoItems($payload, $jaxl) {
            if(!is_array($payload['queryItemJid']))
                return $payload;

            $items = array_unique($payload['queryItemJid']);
            foreach($items as $item)
                $jaxl->discoInfo($item, array($this, 'handleDiscoInfo'));
        }

        function handleDiscoInfo($payload, $jaxl) {
             print_r($payload);
        }

        function postRosterUpdate($payload, $jaxl) {
            // Use $jaxl->roster which holds retrived roster list
             print_r($jaxl->roster);

            // set echobot status
            $jaxl->setStatus(false, false, false, true);
        }
       
        function getMessage($payloads, $jaxl) {
            foreach($payloads as $payload) {
                if($payload['offline'] != JAXL0203::$ns) {
                    if(strlen($payload['body']) > 0) {
                         echo "back the incoming message";
                        $jaxl->sendMessage($payload['from'], $payload['body']);
                    }
                }
            }
        }
       
        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;
        }
       
        function sendMessage($to, $message, $from=false, $type='chat', $id=false) {
            $child = array();
            $child['body'] = $message;
            return XMPPSend::message($this, $to, $from, $child, $type, $id);
        }
    }

   
   
    // 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_send_message', array($echobot, 'sendMessage'));
    $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");
 
plz help me for solve this problem............
Reply all
Reply to author
Forward
0 new messages