]> jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/blame_incremental - README.md
Return from $rpc->eventloop() after 2 seconds instead of 10.
[irc/unrealircd/unrealircd-rpc-php.git] / README.md
... / ...
CommitLineData
1UnrealIRCd RPC
2==============
3
4This allows PHP scripts to control [UnrealIRCd](https://www.unrealircd.org/)
5via the [JSON-RPC interface](https://www.unrealircd.org/docs/JSON-RPC).
6
7This library is used by the
8[UnrealIRCd webpanel](https://github.com/unrealircd/unrealircd-webpanel/).
9
10If you are interested in helping out or would like to discuss API
11capabilities, join us at `#unreal-webpanel` at `irc.unrealircd.org`
12(IRC with TLS on port 6697).
13
14Installation
15------------
16```bash
17composer require unrealircd/unrealircd-rpc:dev-main
18```
19
20UnrealIRCd setup
21-----------------
22UnrealIRCd 6.0.6 or later is needed and you need to enable
23[JSON-RPC](https://www.unrealircd.org/docs/JSON-RPC) in it.
24After doing that, be sure to rehash the IRCd.
25
26Usage
27-----
28For this example, create a file like `src/rpctest.php` with:
29```php
30<?php
31 require dirname(__DIR__) . '/vendor/autoload.php';
32
33 use UnrealIRCd\Connection;
34
35 $api_login = 'api:apiPASSWORD'; // same as in the rpc-user block in UnrealIRCd
36
37 $rpc = new UnrealIRCd\Connection("wss://127.0.0.1:8600/",
38 $api_login,
39 Array("tls_verify"=>FALSE));
40
41 $bans = $rpc->serverban()->getAll();
42 foreach ($bans as $ban)
43 echo "There's a $ban->type on $ban->name\n";
44
45 $users = $rpc->user()->getAll();
46 foreach ($users as $user)
47 echo "User $user->name\n";
48
49 $channels = $rpc->channel()->getAll();
50 foreach ($channels as $channel)
51 echo "Channel $channel->name ($channel->num_users user[s])\n";
52```
53Then, run it on the command line with `php src/rpctest.php`
54
55If the example does not work, then make sure you have configured your
56UnrealIRCd correctly, with the same API username and password you use
57here, with an allowed IP, and changing the `wss://127.0.0.1:8600/` too
58if needed.