====== PHP Jabber library (class.jabber2.php) ====== ===== About ===== This new Jabber library for PHP has been created for the [[start|Flyspray]] project because of the lack of any usable Jabber library. So far it is the only one which supports SASL authentication which is required by most modern Jabber servers. ===== Download ===== The Jabber library is located in our SVN repository, but you can always download the **[[http://svn.ivt.com.au/flyspray/trunk/includes/class.jabber2.php|latest revision]]** without any SVN client. A [[http://fisheye3.cenqua.com/browse/flyspray/trunk/includes/class.jabber2.php|"changelog" and nicer view]] is available as well. ===== Usage ===== It's rather simple to use, so we'll give an example which should pretty much tell it all. require('class.jabber2.php'); // this is the most simple way of initlialising a new instance of the Jabber class $jabber = new Jabber('username@server.org', 'password'); // or this one, has it all // SECURITY_NONE = neither SSL nor TLS is used // or SECURITY_SSL = use SSL // SECURITY_TLS = use TLS [last two require the openssl extension for PHP] // 5222 = port number // 'localhost' = add this parameter, if server.org is not the host // you want to connect to (but to localhost instead in this case) $jabber = new Jabber('username@server.org', 'password', SECURITY_NONE, 5222, 'localhost'); // register the account with the data above $jabber->register(); // or login with data from above (or both, one after the other) $jabber->login(); // set presence $jabber->presence(); // full version: $jabber->presence($type [dnd, away, chat, xa], $message [string], $unavailable [bool]) // check for incoming messages, do that after setting the presence only print_r($jabber->get_messages()); // send a message $jabber->send_message('mybuddy@server.org', 'message body', 'subject'); // if you don't like your account anymore... $jabber->unregister(); $jabber->disconnect(); // this will give you a debug log print_r(array_map('htmlspecialchars', $jabber->log)); This all the Jabber library can do so far, but I guess it covers all the most important actions.