-
Notifications
You must be signed in to change notification settings - Fork 6
Examples
dave-p edited this page Jan 14, 2018
·
16 revisions
Parameters passed to TVH using the GET method must be URI-encoded:
curl 'http://user:pass@localhost:9981/api/epg/events/grid?limit=999&channel=BBC%20ONE'
Alternatively use the POST Method:
curl --data 'limit=999&channel=BBC ONE' 'http://user:pass@localhost:9981/api/epg/events/grid'
To make the output more human-readable, pipe it through json_pp (included in the perl package on many distributions).
This simple example lists some details about upcoming timers, sorted in date order. To work through a PHP-enabled web server, the PHP.INI setting "allow_url_fopen" must be ON.
$timers = get_timers();
foreach($timers as $t) {
$start = strftime("%H:%M", $t["start"]);
$stop = strftime("%H:%M", $t["stop"]);
$date = strftime("%a %e/%m", $t["start"]);
echo "Date: $date, Start: $start, End: $stop, Title: {$t['disp_title']}";
}
function get_timers() {
$url = "http://admin:admin@localhost:9981/api/dvr/entry/grid_upcoming?sort=start";
$json = file_get_contents($url);
$j = json_decode($json, true);
$ret = &$j["entries"];
return $ret;
}
For an example of what can be done with the API in PHP see https://github.com/dave-p/TVHadmin.