Beispiel #1
0
 /**
  * Make a call to the API
  * 
  * @param string $method HTTP method to use
  * @param string $url URL
  * @param array $params API parameters
  * @param boolean $throw_exception True to throw exceptoins
  * @throws APIException, APIAuthException
  * @return  \Instagram\Net\ApiResponse Returns teh API response
  * @access private
  */
 private function apiCall($method, $url, array $params = null, $throw_exception = true)
 {
     $raw_response = $this->client->{$method}($url, array('access_token' => $this->access_token, 'client_id' => isset($params['client_id']) ? $params['client_id'] : $this->client_id) + (array) $params);
     $response = new \Instagram\Net\ApiResponse($raw_response);
     if (!$response->isValid()) {
         if ($throw_exception) {
             if ($response->getErrorType() == 'OAuthAccessTokenException') {
                 throw new \Instagram\Core\ApiAuthException($response->getErrorMessage(), $response->getErrorCode(), $response->getErrorType());
             } else {
                 throw new \Instagram\Core\ApiException($response->getErrorMessage(), $response->getErrorCode(), $response->getErrorType());
             }
         } else {
             return false;
         }
     }
     $headers = $response->getHeaders();
     if (isset($headers['X-Ratelimit-Remaining'])) {
         $this->requests_remaining = $headers['X-Ratelimit-Remaining'];
     }
     return $response;
 }