]> jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/blob - README.md
Return from $rpc->eventloop() after 2 seconds instead of 10.
[irc/unrealircd/unrealircd-rpc-php.git] / README.md
1 UnrealIRCd RPC
2 ==============
3
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).
6
7 This library is used by the
8 [UnrealIRCd webpanel](https://github.com/unrealircd/unrealircd-webpanel/).
9
10 If you are interested in helping out or would like to discuss API
11 capabilities, join us at `#unreal-webpanel` at `irc.unrealircd.org`
12 (IRC with TLS on port 6697).
13
14 Installation
15 ------------
16 ```bash
17 composer require unrealircd/unrealircd-rpc:dev-main
18 ```
19
20 UnrealIRCd setup
21 -----------------
22 UnrealIRCd 6.0.6 or later is needed and you need to enable
23 [JSON-RPC](https://www.unrealircd.org/docs/JSON-RPC) in it.
24 After doing that, be sure to rehash the IRCd.
25
26 Usage
27 -----
28 For 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 ```
53 Then, run it on the command line with `php src/rpctest.php`
54
55 If the example does not work, then make sure you have configured your
56 UnrealIRCd correctly, with the same API username and password you use
57 here, with an allowed IP, and changing the `wss://127.0.0.1:8600/` too
58 if needed.