forked from fabiang/xmpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.php
38 lines (28 loc) · 837 Bytes
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
require 'vendor/autoload.php';
error_reporting(-1);
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Fabiang\Xmpp\Options;
use Fabiang\Xmpp\Client;
use Fabiang\Xmpp\Protocol\Roster;
use Fabiang\Xmpp\Protocol\Presence;
use Fabiang\Xmpp\Protocol\Message;
$logger = new Logger('xmpp');
$logger->pushHandler(new StreamHandler('php://stdout', Logger::DEBUG));
$hostname = 'localhost';
$port = 5222;
$connectionType = 'tcp';
$address = "$connectionType://$hostname:$port";
$username = 'xmpp';
$password = 'test';
$options = new Options($address);
$options->setLogger($logger)
->setUsername($username)
->setPassword($password);
$client = new Client($options);
$client->connect();
$client->send(new Roster);
$client->send(new Presence);
$client->send(new Message);
$client->disconnect();