2008-04-02 08:09:28 +01:00
|
|
|
<?php
|
2019-06-18 19:02:40 +01:00
|
|
|
/**
|
|
|
|
* @file: XMPPHP Send message example
|
|
|
|
*
|
|
|
|
* @info: If this script doesn't work, are you running 64-bit PHP with < 5.2.6?
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* Activate full error reporting
|
|
|
|
* error_reporting(E_ALL & E_STRICT);
|
|
|
|
*
|
|
|
|
* XMPPHP Log levels:
|
|
|
|
*
|
|
|
|
* LEVEL_ERROR = 0;
|
|
|
|
* LEVEL_WARNING = 1;
|
|
|
|
* LEVEL_INFO = 2;
|
|
|
|
* LEVEL_DEBUG = 3;
|
|
|
|
* LEVEL_VERBOSE = 4;
|
|
|
|
*/
|
2008-04-28 23:05:31 +01:00
|
|
|
|
2019-11-02 23:36:21 +00:00
|
|
|
$conf = [
|
|
|
|
'server' => 'jabber.domain.com',
|
|
|
|
'port' => 5222,
|
|
|
|
'username' => 'username',
|
|
|
|
'password' => 'password',
|
|
|
|
'proto' => 'xmpphp',
|
|
|
|
'domain' => 'domain.net',
|
|
|
|
'printlog' => true,
|
|
|
|
'loglevel' => XMPPHP\Log::LEVEL_VERBOSE,
|
|
|
|
];
|
2019-06-18 19:02:40 +01:00
|
|
|
|
|
|
|
// Easy and simple for access to variables with their names
|
|
|
|
extract($conf);
|
|
|
|
|
|
|
|
$XMPP = new XMPPHP\XMPP($server, $port, $username, $password, $proto, $domain, $printlog, $loglevel);
|
2008-05-05 20:50:02 +01:00
|
|
|
|
|
|
|
try {
|
2019-06-18 19:02:40 +01:00
|
|
|
$XMPP->connect();
|
|
|
|
$XMPP->processUntil('session_start', 10);
|
|
|
|
$XMPP->presence();
|
|
|
|
$XMPP->message('target.user@jabber.domain.com', 'Hello, how are you?', 'chat');
|
|
|
|
$XMPP->disconnect();
|
|
|
|
} catch (XMPPHP\Exception $e) {
|
2008-05-05 20:50:02 +01:00
|
|
|
die($e->getMessage());
|
2008-07-17 00:07:01 +01:00
|
|
|
}
|