Tuesday, June 3, 2008

XML-RPC ejabberd class for PHP

Hi, recently i have created some simple PHP class for ejabberd mod_xmlrpc module. You can grab if from Process-one repository here. Expect more updates of this class as i will add new calls soon.
Here is example how simple and fast your PHP program may contact to ejabberd server for authentication (example with exception support) :


<?
include("class.ejabberd_xmlrpc.php");

$ejabberd_rpc = new rpc_connector("192.168.0.1","4666","jabster.pl","test","123456");

try {

    if(
$ejabberd_rpc->auth() === true) {
                                                          
define(AUTHENTICATED,true);
                            }
                            else{
                                                          
define(AUTHENTICATED,false);
     }

}
catch (
Exception $e) {

    echo 
"Exception: ".$e->getMessage();
    echo 
", Code: ".$e->getCode();
    
define(AUTHENTICATED,false);

}


var_dump(AUTHENTICATED);

?>



see source for detailed usage and available methods. This class will evolve so watch the commits on proccess-one.