Ejemplo n.º 1
0
 /**
  * Sends request for banner stats.
  *
  * @param array $params Stats query params.
  *
  * @return array
  * @throws YandexDirectException
  * @throws \Bitrix\Main\SystemException
  *
  * @see https://tech.yandex.ru/direct/doc/dg-v4/live/GetBannersStat-docpage/
  */
 public function getBannerStats(array $params)
 {
     $result = $this->query(static::METHOD_STAT_BANNER, $params);
     $result = YandexJson::decode($result->getResult());
     if (!empty($result['error_code'])) {
         throw new YandexDirectException($result);
     }
     return $result["data"];
 }
Ejemplo n.º 2
0
 public function finance_query($method, $masterToken, $operationNum, $param = array(), $skipRefreshAuth = false)
 {
     if ($this->engineSettings['AUTH']) {
         $http = new HttpClient();
         $http->setRedirect(false);
         $http->setHeader("Content-Type", "application/json; charset=utf-8");
         $auth = $this->getCurrentUser();
         $financeToken = hash("sha256", $masterToken . $operationNum . $method . $auth['login']);
         $postData = array("method" => $method, "finance_token" => $financeToken, "operation_num" => $operationNum, "locale" => $this->locale, "token" => $this->engineSettings['AUTH']['access_token']);
         if (!empty($param)) {
             $postData["param"] = $param;
         }
         $postData = YandexJson::encode($postData, JSON_UNESCAPED_UNICODE);
         $http->post(self::API_URL, $postData);
         if ($http->getStatus() == 401 && !$skipRefreshAuth) {
             if ($this->checkAuthExpired(false)) {
                 $this->query($method, $param, true);
             }
         }
         return $http;
     } else {
         throw new SystemException("No Yandex auth data");
     }
 }