<?php
$getheads = json_decode(file_get_contents("headers.json"));
$fileurl = "/filename/bearer.php";
$replace = $getheads->filename;
$filename = str_replace('/filename', '/' . $replace, $fileurl);
$reading = file_get_contents($filename);
include('../Requests-1.7.0/library/Requests.php');
$token = 'Bearer '.$reading;
Requests::register_autoloader();
$headers = array(
    'Referer' => $getheads->referer,
    'Accept' => '*/*',
    'User-Agent' => 'Mozilla/5.0 (QtEmbedded; U; Linux; C) AppleWebKit/533.3 (KHTML, like Gecko) MAG200 stbapp ver: 2 rev: 250 Safari/533.3',
    'X-User-Agent' => 'Model: MAG250; Link: WiFi',
    'Authorization' => $token,
    'Host' => $getheads->host,
    'Connection' => 'Keep-Alive',
    'Accept-Encoding' => 'gzip',
    'Cookie' => $getheads->mac
);
$response = Requests::get($getheads->portal.'?type=itv&action=get_all_channels&force_ch_link_check=&JsHttpRequest=1-xml', $headers);
$json = json_decode(json_encode($response), true);
#print_r($response);
$json1 = json_decode(array_values($json)[0], true);
#$token = $json1['js']['token'];
print_r($json);
echo json_encode($arr);