]> jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/blame - README.md
Update Channel.php
[irc/unrealircd/unrealircd-rpc-php.git] / README.md
CommitLineData
562c96c0
BM
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
f228c2d5
BM
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
66eda38d
BM
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).
562c96c0
BM
17
18Installation
19------------
20```bash
27d8a778 21composer require unrealircd/unrealircd-rpc:dev-main
562c96c0
BM
22```
23
66eda38d
BM
24UnrealIRCd setup
25-----------------
f228c2d5 26UnrealIRCd 6.0.5 is needed and you need to configure it as explained in
66eda38d
BM
27https://www.unrealircd.org/docs/JSON-RPC.
28
f228c2d5 29After doing that, be sure to rehash the IRCd.
66eda38d 30
562c96c0
BM
31Usage
32-----
e3d9bcad 33For this example, create a file like `src/rpctest.php` with:
562c96c0
BM
34```php
35<?php
36 require dirname(__DIR__) . '/vendor/autoload.php';
37
66eda38d 38 use UnrealIRCd\Connection;
562c96c0 39
66eda38d 40 $api_login = 'api:apiPASSWORD'; // same as in the rpc-user block in UnrealIRCd
562c96c0 41
66eda38d 42 $rpc = new UnrealIRCd\Connection("wss://127.0.0.1:8000/",
562c96c0
BM
43 $api_login,
44 Array("tls_verify"=>FALSE));
45
66eda38d 46 $bans = $rpc->serverban()->getAll();
93f8a3ee 47 foreach ($bans as $ban)
66eda38d
BM
48 echo "There's a $ban->type on $ban->name\n";
49
50 $users = $rpc->user()->getAll();
93f8a3ee 51 foreach ($users as $user)
66eda38d
BM
52 echo "User $user->name\n";
53
54 $channels = $rpc->channel()->getAll();
93f8a3ee 55 foreach ($channels as $channel)
66eda38d 56 echo "Channel $channel->name ($channel->num_users user[s])\n";
562c96c0 57```
e3d9bcad
BM
58And then run it on the command line with `php src/rpctest.php`
59
66eda38d
BM
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.