- Модуль: seo
- Путь к файлу: ~/bitrix/modules/seo/lib/engine/yandex.php
- Класс: BitrixSeoEngineYandex
- Вызов: Yandex::getSiteInfoQueries
public function getSiteInfoQueries($domain)
{
$domain = ToLower($domain);
$hostId = $this->getHostId($domain);
// get TOTAL_SHOWS
$params = array(
"order_by" => "TOTAL_SHOWS",
"query_indicator" => "TOTAL_SHOWS",
);
$serviceUrl = $this->getServiceUrl($this->userId, $hostId, self::API_POPULAR_URL, $params);
// dirt hack - our construcotr not understand multiply params
$serviceUrl .= '&query_indicator=TOTAL_CLICKS';
$serviceUrl .= '&query_indicator=AVG_SHOW_POSITION';
$serviceUrl .= '&query_indicator=AVG_CLICK_POSITION';
$queryResult = $this->query($serviceUrl, 'GET');
if ($queryResult->getStatus() == self::HTTP_STATUS_OK && $queryResult->getResult() <> '')
$queriesShows = Json::decode($queryResult->getResult());
else
throw new EngineYandexException($queryResult);
// format out array
$result = array();
$totalShows = 0;
$totalClicks = 0;
foreach($queriesShows['queries'] as $key => $query)
{
$result[$key] = array(
'TEXT' => $query['query_text'],
'TOTAL_SHOWS' => $query['indicators']['TOTAL_SHOWS'],
'TOTAL_CLICKS' => $query['indicators']['TOTAL_CLICKS'],
'AVG_SHOW_POSITION' => is_null($query['indicators']['AVG_SHOW_POSITION']) ? '' :round($query['indicators']['AVG_SHOW_POSITION'], 1),
'AVG_CLICK_POSITION' => is_null($query['indicators']['AVG_CLICK_POSITION']) ? '' :round($query['indicators']['AVG_CLICK_POSITION'], 1),
);
$totalShows += $query['indicators']['TOTAL_SHOWS'];
$totalClicks += $query['indicators']['TOTAL_CLICKS'];
}
return array(
'QUERIES' => $result,
'DATE_FROM' => $queriesShows['date_from'],
'DATE_TO' => $queriesShows['date_to'],
'TOTAL_SHOWS' => $totalShows,
'TOTAL_CLICKS' => $totalClicks,
);
}