protected function doRequest(Client $client, $url, $options = array())
    {
        $options += array(
            'urlParams' => array(),
            'queryParams' => array(),
            'method' => static::METHOD_GET,
        );
        $token = $client->getToken();

        // Replace parameters in the url.
        $urlReplacements = $this->getParameterReplacements($options['urlParams'], $token);
        $url = str_replace(array_keys($urlReplacements), array_values($urlReplacements), $url);

        // Replace query parameters.
        $queryReplacements = $this->getParameterReplacements($options['queryParams'], $token);
        $queryParams = array_merge($options['queryParams'], $queryReplacements);

        // Process query parameters.
        $queryParams = $this->processQueryParameters($queryParams);

        // Set the request uri.
        $client->setUri($this->credentials->getEnvironment()->getBaseUrl() . $url);

        // Set the parameters.
        switch ($options['method']) {
            case static::METHOD_POST:
                $client->setParameterPost($queryParams);
                break;

            case static::METHOD_GET:
            default:
                $client->setParameterGet($queryParams);
                break;
        }

        // Set the request method and send the request.
        $client->setMethod($options['method']);
        $response = $client->send();

        // Below are all possible error codes as described bij de api
        // documentation.
        $statusCode = $response->getStatusCode();
        switch ($statusCode) {
            // No content.
            case 204:
                return null;
            // Bad request.
            case 400:
            // Missing Authorization header.
            case 401:
            // Unauthorized.
            case 403:
            // Not found.
            case 404:
            // Misdirected request.
            case 421:
            // Any other undocumented error codes.
            case $statusCode >= 400:
                throw new BibException($response->getReasonPhrase(), $response->getStatusCode());
        }
        $doc = new \DOMDocument();
        $doc->loadXML($response->getBody());
        return $doc;
    }
protected function doRequest(Client $client, $url, $options = array())
    {
        $options += array(
            'urlParams' => array(),
            'queryParams' => array(),
            'method' => static::METHOD_GET,
        );
        $token = $client->getToken();

        // Replace parameters in the url.
        $urlReplacements = $this->getParameterReplacements($options['urlParams'], $token);
        $url = str_replace(array_keys($urlReplacements), array_values($urlReplacements), $url);

        // Replace query parameters.
        $queryReplacements = $this->getParameterReplacements($options['queryParams'], $token);
        $queryParams = array_merge($options['queryParams'], $queryReplacements);

        // Process query parameters.
        $queryParams = $this->processQueryParameters($queryParams);

        // Set the request uri.
        $client->setUri($this->credentials->getEnvironment()->getBaseUrl() . $url);

        // Set the parameters.
        switch ($options['method']) {
            case static::METHOD_POST:
                $client->setParameterPost($queryParams);
                break;

            case static::METHOD_GET:
            default:
                $client->setParameterGet($queryParams);
                break;
        }

        // Set the request method and send the request.
        $client->setMethod($options['method']);
        $response = $client->send();

        // Below are all possible error codes as described bij de api
        // documentation.
        $statusCode = $response->getStatusCode();
        switch ($statusCode) {
            // No content.
            case 204:
                return null;
            // Bad request.
            case 400:
            // Missing Authorization header.
            case 401:
            // Unauthorized.
            case 403:
            // Not found.
            case 404:
            // Misdirected request.
            case 421:
            // Any other undocumented error codes.
            case $statusCode >= 400:
                throw new BibException($response->getReasonPhrase(), $response->getStatusCode());
        }
        $doc = new \DOMDocument();
        $doc->loadXML($response->getBody());
        return $doc;
    }
protected function doRequest ( Client $ client , $ url , $ options = array ( ) ) { $ options += array ( 'urlParams' => array ( ) , 'queryParams' => array ( ) , 'method' => static :: METHOD_GET , ) ; $ token = $ client -> getToken ( ) ; // Replace parameters in the url. $ urlReplacements = $ this -> getParameterReplacements ( $ options [ 'urlParams' ] , $ token ) ; $ url = str_replace ( array_keys ( $ urlReplacements ) , array_values ( $ urlReplacements ) , $ url ) ; // Replace query parameters. $ queryReplacements = $ this -> getParameterReplacements ( $ options [ 'queryParams' ] , $ token ) ; $ queryParams = array_merge ( $ options [ 'queryParams' ] , $ queryReplacements ) ; // Process query parameters. $ queryParams = $ this -> processQueryParameters ( $ queryParams ) ; // Set the request uri. $ client -> setUri ( $ this -> credentials -> getEnvironment ( ) -> getBaseUrl ( ) . $ url ) ; // Set the parameters. switch ( $ options [ 'method' ] ) { case static :: METHOD_POST : $ client -> setParameterPost ( $ queryParams ) ; break ; case static :: METHOD_GET : default : $ client -> setParameterGet ( $ queryParams ) ; break ; } // Set the request method and send the request. $ client -> setMethod ( $ options [ 'method' ] ) ; $ response = $ client -> send ( ) ; // Below are all possible error codes as described bij de api // documentation. $ statusCode = $ response -> getStatusCode ( ) ; switch ( $ statusCode ) { // No content. case 204 : return null ; // Bad request. case 400 : // Missing Authorization header. case 401 : // Unauthorized. case 403 : // Not found. case 404 : // Misdirected request. case 421 : // Any other undocumented error codes. case $ statusCode >= 400 : throw new BibException ( $ response -> getReasonPhrase ( ) , $ response -> getStatusCode ( ) ) ; } $ doc = new \ DOMDocument ( ) ; $ doc -> loadXML ( $ response -> getBody ( ) ) ; return $ doc ; }
Executes a request.

@param \ZendOAuth\Client $client
The client that will execute the request.
@param string $url
The URL to request.
@param array $options
An array of options:
- urlParams: An array of replacements for the url:
$url: 'https://mijn.bibliotheek.be/openbibid/rest/library/id/:id'
urlParams: [':id' => 2199]
Values between {} are taken from the access token:
$url:
'https://mijn.bibliotheek.be/openbibid/rest/user/info/:userId'
urlParams: [':userId' => '{userId}']
- queryParams: An array of query parameters for GET requests or POST
data for POST requests.
- method: One of the \Zend\Http\Request::METHOD_* constants.

@return \DOMDocument|null
A \DOMDocument containing the XML from the response, null if HTTP
status
code 204 (No content) was returned.

@throws \OpenBibIdApi\Exception\BibException
When any of the 400, 401, 403, 404 or 421 status codes were returned.
Executes a request .