protected function queryOld($scope, $method = "GET", $data = null, $skipRefreshAuth = false) { if ($this->engineSettings['AUTH']) { $http = new \CHTTP(); $http->setAdditionalHeaders(array('Authorization' => 'OAuth ' . $this->engineSettings['AUTH']['access_token'])); $http->setFollowRedirect(false); switch ($method) { case 'GET': $result = $http->get($scope); break; case 'POST': $result = $http->post($scope, $data); break; case 'PUT': $result = $http->httpQuery($method, $scope, $http->prepareData($data)); break; case 'DELETE': break; } if ($http->status == 401 && !$skipRefreshAuth) { if ($this->checkAuthExpired(false)) { $this->queryOld($scope, $method, $data, true); } } $http->result = Text\Encoding::convertEncoding($http->result, 'utf-8', LANG_CHARSET); return $http; } }
protected function query($scope, $method = "GET", $data = null, $bSkipRefreshAuth = false, $contentType = 'application/atom+xml') { if ($this->engineSettings['AUTH']) { $http = new \CHTTP(); $http->setAdditionalHeaders(array('Authorization' => 'Bearer ' . $this->engineSettings['AUTH']['access_token'], 'GData-Version' => '2')); switch ($method) { case 'GET': $result = $http->get($scope); break; case 'POST': case 'PUT': $arUrl = $http->parseURL($scope); $result = $http->query($method, $arUrl['host'], $arUrl['port'], $arUrl['path_query'], $data, $arUrl['proto'], $contentType); break; case 'DELETE': break; } if ($http->status == 401 && !$bSkipRefreshAuth) { if ($this->checkAuthExpired(true)) { return $this->query($scope, $method, $data, true, $contentType); } } return $http; } }