$cache = new CPHPCache();
$cache_time = 3600;
$cache_id = 'marketQuery'
$cache_path = 'yaMarket';
if ($cache_time > 0 && $cache->InitCache($cache_time, $cache_id, $cache_path))
{
$res = $cache->GetVars();
if (is_array($res["marketQuery"]) && (count($res["marketQuery"]) > 0))
$yaMarket = $res["marketQuery"];
}
if (!empty($yaMarket))
{
$url = "https://api.content.market.yandex.ru/v1/shop/302613/opinion.xml?sort=rank&count=1";
$headers = array(
"Host: api.content.market.yandex.ru",
"Accept: */*",
"Authorization: 98c671b8-a96a-444a-8c53-660b4c63d4e2"
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$data = curl_exec($ch);
curl_close($ch);
$yaMarket = $data;
//////////// end cache /////////
if ($cache_time > 0)
{
$cache->StartDataCache($cache_time, $cache_id, $cache_path);
$cache->EndDataCache(array("marketQuery"=> $yaMarket));
}
}
CJSCore::Init(array("fx"));