]> jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/blame_incremental - README.md
Update Channel.php
[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
7WARNING: Both the UnrealIRCd-side and this PHP library are under heavy
8development so major API breakages are likely, such as changing the
9function names, arguments that need to be passed and the way things
10are returned.
11
12If you are interested in helping out or would like to discuss API
13capabilities, join us at `#unreal-webpanel` at irc.unrealircd.org
14(IRC with TLS on port 6697).
15
16See also [Looking for webdevs to make UnrealIRCd webpanel](https://forums.unrealircd.org/viewtopic.php?t=9257).
17
18Installation
19------------
20```bash
21composer require unrealircd/unrealircd-rpc:dev-main
22```
23
24UnrealIRCd setup
25-----------------
26UnrealIRCd 6.0.5 is needed and you need to configure it as explained in
27https://www.unrealircd.org/docs/JSON-RPC.
28
29After doing that, be sure to rehash the IRCd.
30
31Usage
32-----
33For this example, create a file like `src/rpctest.php` with:
34```php
35<?php
36 require dirname(__DIR__) . '/vendor/autoload.php';
37
38 use UnrealIRCd\Connection;
39
40 $api_login = 'api:apiPASSWORD'; // same as in the rpc-user block in UnrealIRCd
41
42 $rpc = new UnrealIRCd\Connection("wss://127.0.0.1:8000/",
43 $api_login,
44 Array("tls_verify"=>FALSE));
45
46 $bans = $rpc->serverban()->getAll();
47 foreach ($bans as $ban)
48 echo "There's a $ban->type on $ban->name\n";
49
50 $users = $rpc->user()->getAll();
51 foreach ($users as $user)
52 echo "User $user->name\n";
53
54 $channels = $rpc->channel()->getAll();
55 foreach ($channels as $channel)
56 echo "Channel $channel->name ($channel->num_users user[s])\n";
57```
58And then run it on the command line with `php src/rpctest.php`
59
60If the example does not work, then make sure you have configured your
61UnrealIRCd correctly, with the same API username and password you use
62here, and with an allowed IP, and changing the `127.0.0.1:8000` too
63if needed.