-
Notifications
You must be signed in to change notification settings - Fork 1
/
tvdbEpisode.php
38 lines (33 loc) · 927 Bytes
/
tvdbEpisode.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
<?php
include_once "auth.php";
include_once "./template/functions.php";
$idEpisode = getEscGet('idEp');
if (empty($idEpisode)) {
echo null;
return;
}
$TOKEN = authTvDB();
if (empty($TOKEN)) {
echo null;
return;
}
$LANG = isset($GLOBALS['TVDB_LANGUAGE']) ? $GLOBALS['TVDB_LANGUAGE'] : 'en';
$URL = 'https://api.thetvdb.com/episodes/'.$idEpisode;
$opts = array('http' => array(
'method' => 'GET',
'timeout' => getTimeOut(),
'header' => 'Accept:application/json'."\r\n".'Accept-Language:'.$LANG."\r\n".'Authorization:Bearer '.$TOKEN
));
$context = stream_context_create($opts);
$json = null;
$oldHandler = set_error_handler('handleError');
try {
$json = file_get_contents($URL, false, $context);
} catch (Exception $e) {
if (!empty($oldHandler)) { set_error_handler($oldHandler); }
echo null;
return;
}
if (!empty($oldHandler)) { set_error_handler($oldHandler); }
echo $json;
?>