]> jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/blob - README.md
Import of initial proof-of-concept
[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 Currently this is just a proof-of-concept:
8 * It allows you to connect only using websockets
9 * It has only 1 function (`query`) to send a JSON-RPC request and receive a response,
10 which is low-level. You need to know *exactly* what method to call and with
11 what parameters. So there is no `listUsers` or things like that.
12 * There is only limited error checking
13 * Etc...
14
15 This is just a proof-of-concept to get things going and to see if there
16 is interest in making it a more serious library. A serious library would
17 abstract everything and provide functions such as `listUsers`, `listServerBans`,
18 `addServerBan`, etc. That way the programmer using it would not need to
19 know anything about JSON-RPC at all.
20
21 If you are interested in helping out to achieve that, join us at
22 #unreal-webpanel at irc.unrealircd.org (IRC with TLS on port 6697).
23
24 See also [Looking for webdevs to make UnrealIRCd webpanel](https://forums.unrealircd.org/viewtopic.php?t=9195),
25 both the 1st and 2nd post there in particular.
26
27 Installation
28 ------------
29 ```bash
30 composer require unrealircd/unrealircd-rpc
31 ```
32
33 Usage
34 -----
35 ```php
36 <?php
37 require dirname(__DIR__) . '/vendor/autoload.php';
38
39 use UnrealIRCdRPC\Connection;
40
41 $api_login = 'api:password';
42
43 $rpc = new UnrealIRCdRPC\Connection("wss://127.0.0.1:8000/",
44 $api_login,
45 Array("tls_verify"=>FALSE));
46
47 $bans = $rpc->query("server_ban.list");
48 foreach ($bans->list as $ban)
49 echo $ban->type . " at " . $ban->name . "\n";
50 ```