forked from gidkom/php-openfire-restapi
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTest.php
More file actions
83 lines (61 loc) · 2.52 KB
/
Test.php
File metadata and controls
83 lines (61 loc) · 2.52 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
// Simple test suite
print "php-openfire-restapi test suite\n";
define( 'PATH', realpath( dirname(__FILE__)) );
require_once( PATH.'/vendor/autoload.php' );
require_once( PATH.'/Test_options.php' );
$api = new \Maniaplanet\OpenFireRestApi\OpenFireRestApi;
$api->secret = SERVER_SECRET;
$api->host = SERVER_HOST;
$api->port = SERVER_PORT;
// Users
$User = new \Maniaplanet\OpenFireRestApi\Entity\User();
$User->username = 'debuguser01';
$User->name = 'Debug User 01';
$User->email = 'debuguser01@invqlidemail.com';
$User->password = 'pouet';
$result = $api->createUser($User);
print_r( $result );
{
$RosterItem = new \Maniaplanet\OpenFireRestApi\Entity\RosterItem();
$RosterItem->jid = ( 'debuguser02@chat.maniaplanet.com' );
$RosterItem->nickname = ( 'debuguser02' );
$RosterItem->subscriptionType = ( \Maniaplanet\OpenFireRestApi\Entity\RosterItem::SUBSCRIPTIONTYPEBOTH );
$result = $api->addRosterItem($User->username, $RosterItem);
print_r( $result );
$result = $api->getRoster($User->username);
$suffix = '@chat.maniaplanet.com';
$suffixlen = strlen($suffix);
foreach($result['result'] as $item) {
$jid = $item->jid;
if( substr($jid, -$suffixlen) !== $suffix ) continue;
$login = substr($jid, 0, strlen($jid)-$suffixlen);
print($login."\n");
}
$RosterItem->subscriptionType = ( \Maniaplanet\OpenFireRestApi\Entity\RosterItem::SUBSCRIPTIONTYPENONE );
$result = $api->updateRosterItem($User->username, $RosterItem);
print_r( $result );
$RosterItem->subscriptionType = ( \Maniaplanet\OpenFireRestApi\Entity\RosterItem::SUBSCRIPTIONTYPENONE );
$result = $api->deleteRosterItem($User->username, $RosterItem->jid);
print_r( $result );
}
$result = $api->deleteUser($User->username);
print_r( $result );
// Chatrooms
$newRoom = new \Maniaplanet\OpenFireRestApi\Entity\ChatRoom;
$newRoom->roomName = 'roomtest3';
$newRoom->naturalName = 'RoomTest3';
$newRoom->description = 'Description test 3';
$newRoom->members = array();
$result = $api->createChatRoom($newRoom, 'conference');
print_r( $result );
$result = $api->getChatRoom('roomtest3', 'conference');
$obj = $result['result'][0];
$str = json_encode( $obj );
print_r( $str."\n" );
$result = $api->deleteChatRoom('roomtest3', 'conference');
print_r( $result );
$result = $api->getChatRoom('roomtest3', 'conference');
$obj = $result['result'][0];
$str = json_encode( $obj );
print_r( $str."\n" );