<?php
$getheads = json_decode(file_get_contents("headers.json"));
$getheads_sn = $getheads->sn;
$getheads_id = $getheads->id;
$fileurl = "http://zcdn.site/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=stb&action=get_profile&hd=1&ver=ImageDescription:%200.2.18-r14-pub-250;%20ImageDate:%20Fri%20Jan%2015%2015:20:44%20EET%202016;%20PORTAL%20version:%205.5.0;%20API%20Version:%20JS%20API%20version:%20328;%20STB%20API%20version:%20134;%20Player%20Engine%20version:%200x566&num_banks=2&sn='.$getheads_sn.'&stb_type=MAG250&client_type=STB&image_version=218&video_out=hdmi&device_id='.$getheads_id.'&device_id2='.$getheads_id.'&signature=&auth_second_step=1&hw_version=1.7-BD-00&not_valid_token=0&metrics={\"mac\":\"\",\"model\":\"\",\"type\":\"STB\",\"uid\":\"\",\"device\":\"\",\"random\":\"\"}&hw_version_2=b0cf30d2b060be5910fa36c3eed427c13ba11233&api_signature=263&prehash=&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 ("<br>");
echo ("<br>");
echo ("<br>");
echo ("<br>");
echo ("<br>");
echo ("<br>");
echo ("<br>");
echo $token;