4 This allows PHP scripts to control
[UnrealIRCd](https://www.unrealircd.org/)
5 via the
[JSON-RPC interface](https://www.unrealircd.org/docs/JSON-RPC).
7 WARNING: Both the UnrealIRCd-side and this PHP library are under heavy
8 development so major API breakages are likely, such as changing the
9 function names, arguments that need to be passed and the way things
12 If you are interested in helping out or would like to discuss API
13 capabilities, join us at
`#unreal-webpanel` at irc.unrealircd.org
14 (IRC with TLS on port
6697).
16 See also
[Looking for webdevs to make UnrealIRCd webpanel](https://forums.unrealircd.org/viewtopic.php?t=9257).
21 composer require unrealircd/unrealircd-rpc:dev-main
26 UnrealIRCd
6.0.5 is needed and you need to configure it as explained in
27 https://www.unrealircd.org/docs/JSON-RPC.
29 After doing that, be sure to rehash the IRCd.
33 For this example, create a file like
`src/rpctest.php` with:
36 require dirname(__DIR__) . '/vendor/autoload.php';
38 use UnrealIRCd\Connection;
40 $api_login = 'api:apiPASSWORD'; // same as in the rpc-user block in UnrealIRCd
42 $rpc = new UnrealIRCd\Connection("wss://127.0.0.1:8000/",
44 Array("tls_verify"=>FALSE));
46 $bans = $rpc->serverban()->getAll();
47 foreach ($bans as $ban)
48 echo "There's a $ban->type on $ban->name\n";
50 $users = $rpc->user()->getAll();
51 foreach ($users as $user)
52 echo "User $user->name\n";
54 $channels = $rpc->channel()->getAll();
55 foreach ($channels as $channel)
56 echo "Channel $channel->name ($channel->num_users user[s])\n";
58 And then run it on the command line with
`php src/rpctest.php`
60 If the example does not work, then make sure you have configured your
61 UnrealIRCd correctly, with the same API username and password you use
62 here, and with an allowed IP, and changing the
`127.0.0.1:8000` too