2019-06-23 06:23:21 +09:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @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;
|
|
|
|
*/
|
|
|
|
|
2019-11-17 01:51:01 +09: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-23 06:23:21 +09: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);
|
|
|
|
|
|
|
|
try {
|
|
|
|
$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) {
|
|
|
|
die($e->getMessage());
|
|
|
|
}
|