Ejemplo n.º 1
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");
     }
 }