<?php
$getheads = json_decode(file_get_contents("headers.json"));
include('../Requests-1.7.0/library/Requests.php');
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',
    'Host' => $getheads->host,
    'Connection' => 'Keep-Alive',
    'Accept-Encoding' => 'gzip',
    'Cookie' => $getheads->mac
);
$response = Requests::get($getheads->portal.'?type=stb&action=handshake&token=&prehash=0&JsHttpRequest=1-xml', $headers);
$json = json_decode(json_encode($response),true);
$json1 = json_decode(array_values($json)[0], true);
$token = $json1['js']['token'];
echo $token;