XMPPHP is one of the PHP library to create web-based jabber client. On the site itself says that unlicensed developers XMPPHP XMPPHP is the successor of Class.Jabber.php.
Here I will explain the use XMPPHP little to perform the basic functions jabber, ie, send private messages and send a message to groupchat.
Please know that the main process in the XMPPHP in the handle by a XMLStream.php file. Where in it there are functions to process XML Streaming XMLStream.php addition there are also other supporting a file that is XMPP.php. In this file there are xml handler that will be sent via the XML Socket Stream.
Before we start creating the script, there are some applications and settings that we need to do
1. XMPPHP main files, can be downloaded in You are not allowed to view links.
Register or Loginhttp: / / code.google.com / p / xmpphp
2. PHP server to run a php script, here I am using XAMPP.
3. Extract the files into forlder XMPPHP on xampp htdocs or www folder on some other server php applications.
4. Make sure you activate the extension php_openssl.dll on XAMPP, because we're going to make a connection using SSL on port 5222. You may view your php configuration on phpinfo, and to enable it to open the php.ini file in the folder xampp / apache / bin / php.ini. Remove the ";" in front of the string extension = php_openssl.dll.
5. Connection to the internet.
6. Finally, this process can only be done by PC users
Send a private message (use the good)
In this section I will try to explain how to send a private message to jabber client. Well first you run the xampp server, copy and save the script below as private.php using your favorite text editor:
Code:
connect ();
$ Conn-> processUntil ('session_start');
$ Conn-> presence ();
$ Conn-> message ('maddoc@nimbuzz.com', 'Hello prince_aamir');
$ Conn-> disconnect ();
} Catch (XMPPHP_Exception $ e)
die ($ e-> getMessage ());
}
?>
Explanation of the script above is as follows:
Code:
include 'xmpphp / Log.php';
include 'XMPPHP / XMPP.php';
the script above, we will do inclusi Log.php files and XMPP.php, where there fungsi2 jabber command.
Code:
$ Conn = new XMPPHP_XMPP ('openfire.nimbuzz.com', 5222, 'username', 'password', 'xmpphp', 'nimbuzz.com', $ printlog = false, $ loglevel = XMPPHP_Log:: LEVEL_INFO);
Pieces script above contains host variables, port, username, password and jabber server that will be used. Where the function is contained in XMPP.php
Code:
public function __construct ($ host, $ port, $ user, $ password, $ resource, $ server = null, $ printlog = false, $ loglevel = null) {parent:: __construct ($ host, $ port, $ printlog, $ loglevel);
The above piece of script found on XMPP.php
Code:
$ Conn-> connect ();
The function of the script snippet above is to connect to jabber server.
Code:
$ Conn-> processUntil ('session_start');
$ Conn-> presence ();
This script contains the process will start after the session has started, and send presence to the jabber server.
Code:
conn-> message ('maddoc@nimbuzz.com', 'Hello Prince_aamir');}
$ Conn-> disconnect ();
Potonga script above contains the sender's command, which consists of a user variable mosque and a message. This function is located in XMPP.php
__________________