public function request($url, array $options = array())
    {
        $options += array(
            'data' => null,
            'timeout' => 30,
            'context' => null,
            'method' => 'GET',
            'headers' => array()
        );

        if ($options['method'] === 'POST' && empty($options['headers'])) {
            $options['headers'] = array('Content-Type' => 'application/x-www-form-urlencoded');
        }

        if (!empty($options['query'])) {
            $url = strtok($url, '?') . '?' . http_build_query($options['query']);
        }

        return $this->setUri($url)
            ->setHeaders($options['headers'])
            ->setMethod($options['method'])
            ->setData($options['data'])
            ->setTimeOut($options['timeout'])
            ->setContext($options['context'])
            ->setSocket()
            ->exec()
            ->getFormattedResponse();
    }
public function request($url, array $options = array())
    {
        $options += array(
            'data' => null,
            'timeout' => 30,
            'context' => null,
            'method' => 'GET',
            'headers' => array()
        );

        if ($options['method'] === 'POST' && empty($options['headers'])) {
            $options['headers'] = array('Content-Type' => 'application/x-www-form-urlencoded');
        }

        if (!empty($options['query'])) {
            $url = strtok($url, '?') . '?' . http_build_query($options['query']);
        }

        return $this->setUri($url)
            ->setHeaders($options['headers'])
            ->setMethod($options['method'])
            ->setData($options['data'])
            ->setTimeOut($options['timeout'])
            ->setContext($options['context'])
            ->setSocket()
            ->exec()
            ->getFormattedResponse();
    }
public function request ( $ url , array $ options = array ( ) ) { $ options += array ( 'data' => null , 'timeout' => 30 , 'context' => null , 'method' => 'GET' , 'headers' => array ( ) ) ; if ( $ options [ 'method' ] === 'POST' && empty ( $ options [ 'headers' ] ) ) { $ options [ 'headers' ] = array ( 'Content-Type' => 'application/x-www-form-urlencoded' ) ; } if ( ! empty ( $ options [ 'query' ] ) ) { $ url = strtok ( $ url , '?' ) . '?' . http_build_query ( $ options [ 'query' ] ) ; } return $ this -> setUri ( $ url ) -> setHeaders ( $ options [ 'headers' ] ) -> setMethod ( $ options [ 'method' ] ) -> setData ( $ options [ 'data' ] ) -> setTimeOut ( $ options [ 'timeout' ] ) -> setContext ( $ options [ 'context' ] ) -> setSocket ( ) -> exec ( ) -> getFormattedResponse ( ) ; }
Shortcut method to perform an HTTP request
@param string $url
@param array $options
@return array
Shortcut method to perform an HTTP request