public function query($url, $data = null, $headers = array(), $method = 'get', $timeout = null)
	{
		$token = $this->getToken();

		if (array_key_exists('expires_in', $token) && $token['created'] + $token['expires_in'] < time() + 20)
		{
			if (!$this->getOption('userefresh'))
			{
				return false;
			}

			$token = $this->refreshToken($token['refresh_token']);
		}

		if (!$this->getOption('authmethod') || $this->getOption('authmethod') == 'bearer')
		{
			$headers['Authorization'] = 'Bearer ' . $token['access_token'];
		}
		elseif ($this->getOption('authmethod') == 'get')
		{
			if (strpos($url, '?'))
			{
				$url .= '&';
			}
			else
			{
				$url .= '?';
			}

			$url .= $this->getOption('getparam') ? $this->getOption('getparam') : 'access_token';
			$url .= '=' . $token['access_token'];
		}

		switch ($method)
		{
			case 'head':
			case 'get':
			case 'delete':
			case 'trace':
				$response = $this->http->$method($url, $headers, $timeout);

				break;

			case 'post':
			case 'put':
			case 'patch':
				$response = $this->http->$method($url, $data, $headers, $timeout);

				break;

			default:
				throw new InvalidArgumentException('Unknown HTTP request method: ' . $method . '.');
		}

		if ($response->code < 200 || $response->code >= 400)
		{
			// As of 2.0 this will throw an UnexpectedResponseException
			throw new RuntimeException('Error code ' . $response->code . ' received requesting data: ' . $response->body . '.');
		}

		return $response;
	}
public function query($url, $data = null, $headers = array(), $method = 'get', $timeout = null)
	{
		$token = $this->getToken();

		if (array_key_exists('expires_in', $token) && $token['created'] + $token['expires_in'] < time() + 20)
		{
			if (!$this->getOption('userefresh'))
			{
				return false;
			}

			$token = $this->refreshToken($token['refresh_token']);
		}

		if (!$this->getOption('authmethod') || $this->getOption('authmethod') == 'bearer')
		{
			$headers['Authorization'] = 'Bearer ' . $token['access_token'];
		}
		elseif ($this->getOption('authmethod') == 'get')
		{
			if (strpos($url, '?'))
			{
				$url .= '&';
			}
			else
			{
				$url .= '?';
			}

			$url .= $this->getOption('getparam') ? $this->getOption('getparam') : 'access_token';
			$url .= '=' . $token['access_token'];
		}

		switch ($method)
		{
			case 'head':
			case 'get':
			case 'delete':
			case 'trace':
				$response = $this->http->$method($url, $headers, $timeout);

				break;

			case 'post':
			case 'put':
			case 'patch':
				$response = $this->http->$method($url, $data, $headers, $timeout);

				break;

			default:
				throw new InvalidArgumentException('Unknown HTTP request method: ' . $method . '.');
		}

		if ($response->code < 200 || $response->code >= 400)
		{
			// As of 2.0 this will throw an UnexpectedResponseException
			throw new RuntimeException('Error code ' . $response->code . ' received requesting data: ' . $response->body . '.');
		}

		return $response;
	}
public function query ( $ url , $ data = null , $ headers = array ( ) , $ method = 'get' , $ timeout = null ) { $ token = $ this -> getToken ( ) ; if ( array_key_exists ( 'expires_in' , $ token ) && $ token [ 'created' ] + $ token [ 'expires_in' ] < time ( ) + 20 ) { if ( ! $ this -> getOption ( 'userefresh' ) ) { return false ; } $ token = $ this -> refreshToken ( $ token [ 'refresh_token' ] ) ; } if ( ! $ this -> getOption ( 'authmethod' ) || $ this -> getOption ( 'authmethod' ) == 'bearer' ) { $ headers [ 'Authorization' ] = 'Bearer ' . $ token [ 'access_token' ] ; } elseif ( $ this -> getOption ( 'authmethod' ) == 'get' ) { if ( strpos ( $ url , '?' ) ) { $ url .= '&' ; } else { $ url .= '?' ; } $ url .= $ this -> getOption ( 'getparam' ) ? $ this -> getOption ( 'getparam' ) : 'access_token' ; $ url .= '=' . $ token [ 'access_token' ] ; } switch ( $ method ) { case 'head' : case 'get' : case 'delete' : case 'trace' : $ response = $ this -> http -> $ method ( $ url , $ headers , $ timeout ) ; break ; case 'post' : case 'put' : case 'patch' : $ response = $ this -> http -> $ method ( $ url , $ data , $ headers , $ timeout ) ; break ; default : throw new InvalidArgumentException ( 'Unknown HTTP request method: ' . $ method . '.' ) ; } if ( $ response -> code < 200 || $ response -> code >= 400 ) { // As of 2.0 this will throw an UnexpectedResponseException throw new RuntimeException ( 'Error code ' . $ response -> code . ' received requesting data: ' . $ response -> body . '.' ) ; } return $ response ; }
Send a signed Oauth request.

@param   string  $url      The URL for the request.
@param   mixed   $data     The data to include in the request
@param   array   $headers  The headers to send with the request
@param   string  $method   The method with which to send the request
@param   int     $timeout  The timeout for the request

@return  \Joomla\Http\Response  The http response object.

@since   1.0
@throws  InvalidArgumentException
@throws  RuntimeException
Send a signed Oauth request .