kammy
kammy

Reputation: 352

How to receive Message using openfire server?

I am using Openfire(V 3.9.1) server to send notification from PHP to Android. I am receiving message in Android properly. But I am unable to receive and display reply message back to PHP.

How do I receive/display messages on browser. Should I use a different library? enter image description here

Upvotes: 2

Views: 1159

Answers (2)

Satanand Tiwari
Satanand Tiwari

Reputation: 496

I have made the code for sending message to openfire but i dont know how to retrive the message.

i feel this can help you out.

include './XMPPHP/XMPP_Old.php';
    $host = 'XXX.XXX.XXX.XXX'; // ex.192.168.2.1  
    $port = '5222'; // its defauls xmpp port 
    $username = 'prashant76@mypc'; // ex vivek@host 
    $pass = '########';
    $conn = new XMPPHP_XMPP($host , $port, $username, $pass, 'localhost','localhost', $printlog=false, 

$loglevel=XMPPHP_Log::LEVEL_INFO);  
    try {
       $conn->useEncryption(FALSE);
        //$conn->useSSL(FALSE);
        $str='hello this is messge form php';
        $conn->connect();
        $conn->processUntil('session_start');
        $conn->presence();
        $str= $conn->message('XXXX@XXXXXXXXX', $str); // for sending the message.
        $conn->disconnect(); 
    } catch(XMPPHP_Exception $e) {
             die($e->getMessage()); 
    } 

Upvotes: 2

Syam
Syam

Reputation: 409

You can configure openfire to save messages to mysql database. Then you can either use 'ajax long polling' method or websockets to fetch new records from database and display them on browser. Refer the below links for more details.

Websockets : http://www.html5rocks.com/en/tutorials/websockets/basics/

Ajax long polling PHP : How do I implement basic "Long Polling"?

Upvotes: 0

Related Questions