forked from krixon/xbmc-php-rpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.php
40 lines (37 loc) · 1.17 KB
/
example.php
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
$params = 'xbmc:xbmc@localhost:8080';
require_once 'rpc/HTTPClient.php';
try {
$rpc = new XBMC_RPC_HTTPClient($params);
} catch (XBMC_RPC_ConnectionException $e) {
die($e->getMessage());
}
try {
if ($rpc->isLegacy()) {
$response = $rpc->System->GetInfoLabels(array('System.Time'));
} else {
$response = $rpc->XBMC->GetInfoLabels(array('labels' => array('System.Time')));
}
} catch (XBMC_RPC_Exception $e) {
die($e->getMessage());
}
printf('<p>The current time according to XBMC is %s</p>', $response['System.Time']);
try {
$response = $rpc->JSONRPC->Introspect();
} catch (XBMC_RPC_Exception $e) {
die($e->getMessage());
}
print '<p>The following commands are available according to XBMC:</p>';
if ($rpc->isLegacy()) {
foreach ($response['commands'] as $command) {
printf('<p><strong>%s</strong><br />%s</p>', $command['command'], $command['description']);
}
} else {
foreach ($response['methods'] as $command => $commandData) {
printf(
'<p><strong>%s</strong><br />%s</p>',
$command,
isset($commandData['description']) ? $commandData['description'] : ''
);
}
}