-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathrpctest.pl
More file actions
executable file
·26 lines (20 loc) · 839 Bytes
/
rpctest.pl
File metadata and controls
executable file
·26 lines (20 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/perl
# This is a trivial example of the RPC interface. You'll need RPC::XML
# on your system (not for the server itself, but for this test script).
require RPC::XML;
require RPC::XML::Client;
my $cli = RPC::XML::Client->new('http://localhost:9000/plugins/RPC/rpc.xml');
my $resp = $cli->send_request('slim.doCommand', undef, [ 'player', 'count', '?' ]);
# Some other things to try: (substitute MAC address as appropriate)
#my $resp = $cli->send_request('slim.doCommand', '00:04:20:05:a0:65', [ 'pause' ]);
#my $resp = $cli->send_request('system.listMethods');
if ($resp->is_fault) {
print "Fault: " . $resp->string . "\n";
} else {
if ($resp->isa("RPC::XML::array")) {
print "'" . join("', '", @{$resp->value()}) . "'\n";
} else {
# need a better way to pretty-print the response
print "(Array expected)\n";
}
}