public function fetch($protected_resource_url, $parameters = array(), $http_method = self::HTTP_METHOD_GET, array $http_headers = array(), $form_content_type = self::HTTP_FORM_CONTENT_TYPE_MULTIPART)
    {
        if ($this->access_token) {
            switch ($this->access_token_type) {
                case self::ACCESS_TOKEN_URI:
                    if (is_array($parameters)) {
                        $parameters[$this->access_token_param_name] = $this->access_token;
                    } else {
                        throw new InvalidArgumentException(
                            'You need to give parameters as array if you want to give the token within the URI.',
                            InvalidArgumentException::REQUIRE_PARAMS_AS_ARRAY
                        );
                    }
                    break;
                case self::ACCESS_TOKEN_BEARER:
                    $http_headers['Authorization'] = 'Bearer ' . $this->access_token;
                    break;
                case self::ACCESS_TOKEN_OAUTH:
                    $http_headers['Authorization'] = 'OAuth ' . $this->access_token;
                    break;
                case self::ACCESS_TOKEN_MAC:
                    $http_headers['Authorization'] = 'MAC ' . $this->generateMACSignature($protected_resource_url, $parameters, $http_method);
                    break;
                default:
                    throw new Exception('Unknown access token type.', Exception::INVALID_ACCESS_TOKEN_TYPE);
                    break;
            }
        }
        $http_headers['User-Agent'] = 'drewards/sdk v' . Endpoints::API_VERSION;
        return $this->executeRequest($protected_resource_url, $parameters, $http_method, $http_headers, $form_content_type);
    }
public function fetch($protected_resource_url, $parameters = array(), $http_method = self::HTTP_METHOD_GET, array $http_headers = array(), $form_content_type = self::HTTP_FORM_CONTENT_TYPE_MULTIPART)
    {
        if ($this->access_token) {
            switch ($this->access_token_type) {
                case self::ACCESS_TOKEN_URI:
                    if (is_array($parameters)) {
                        $parameters[$this->access_token_param_name] = $this->access_token;
                    } else {
                        throw new InvalidArgumentException(
                            'You need to give parameters as array if you want to give the token within the URI.',
                            InvalidArgumentException::REQUIRE_PARAMS_AS_ARRAY
                        );
                    }
                    break;
                case self::ACCESS_TOKEN_BEARER:
                    $http_headers['Authorization'] = 'Bearer ' . $this->access_token;
                    break;
                case self::ACCESS_TOKEN_OAUTH:
                    $http_headers['Authorization'] = 'OAuth ' . $this->access_token;
                    break;
                case self::ACCESS_TOKEN_MAC:
                    $http_headers['Authorization'] = 'MAC ' . $this->generateMACSignature($protected_resource_url, $parameters, $http_method);
                    break;
                default:
                    throw new Exception('Unknown access token type.', Exception::INVALID_ACCESS_TOKEN_TYPE);
                    break;
            }
        }
        $http_headers['User-Agent'] = 'drewards/sdk v' . Endpoints::API_VERSION;
        return $this->executeRequest($protected_resource_url, $parameters, $http_method, $http_headers, $form_content_type);
    }
public function fetch ( $ protected_resource_url , $ parameters = array ( ) , $ http_method = self :: HTTP_METHOD_GET , array $ http_headers = array ( ) , $ form_content_type = self :: HTTP_FORM_CONTENT_TYPE_MULTIPART ) { if ( $ this -> access_token ) { switch ( $ this -> access_token_type ) { case self :: ACCESS_TOKEN_URI : if ( is_array ( $ parameters ) ) { $ parameters [ $ this -> access_token_param_name ] = $ this -> access_token ; } else { throw new InvalidArgumentException ( 'You need to give parameters as array if you want to give the token within the URI.' , InvalidArgumentException :: REQUIRE_PARAMS_AS_ARRAY ) ; } break ; case self :: ACCESS_TOKEN_BEARER : $ http_headers [ 'Authorization' ] = 'Bearer ' . $ this -> access_token ; break ; case self :: ACCESS_TOKEN_OAUTH : $ http_headers [ 'Authorization' ] = 'OAuth ' . $ this -> access_token ; break ; case self :: ACCESS_TOKEN_MAC : $ http_headers [ 'Authorization' ] = 'MAC ' . $ this -> generateMACSignature ( $ protected_resource_url , $ parameters , $ http_method ) ; break ; default : throw new Exception ( 'Unknown access token type.' , Exception :: INVALID_ACCESS_TOKEN_TYPE ) ; break ; } } $ http_headers [ 'User-Agent' ] = 'drewards/sdk v' . Endpoints :: API_VERSION ; return $ this -> executeRequest ( $ protected_resource_url , $ parameters , $ http_method , $ http_headers , $ form_content_type ) ; }
Fetch a protected resource

@param string $protected_ressource_url Protected resource URL
@param array  $parameters Array of parameters
@param string $http_method HTTP Method to use (POST, PUT, GET, HEAD, DELETE)
@param array  $http_headers HTTP headers
@param int    $form_content_type HTTP form content type to use
@return array
Fetch a protected resource