Skip to content

Examples

dave-p edited this page Nov 18, 2017 · 16 revisions

Examples

curl

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).

PHP

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.

$urlp = 'http://admin:admin@localhost:9981;'

$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() {
  global $urlp;
  $url = "$urlp/api/dvr/entry/grid_upcoming?sort=start";
  $json = file_get_contents($url);
  $j = json_decode($json, true);
  $ret = &$j["entries"];
  return $ret;
}
Clone this wiki locally