/**
  * @param string $resource
  * @param string $method
  * @return \TYPO3\Flow\Http\Response
  */
 public function query($resource, $method = 'GET')
 {
     $uri = new Uri($this->endpoint . $resource);
     parse_str((string) $uri->getQuery(), $query);
     $query['access_token'] = $this->currentAccessToken;
     $query['appsecret_proof'] = hash_hmac('sha256', $this->currentAccessToken, $this->appSecret);
     $uri->setQuery(http_build_query($query));
     $request = Request::create($uri, $method);
     $response = $this->requestEngine->sendRequest($request);
     return $response;
 }
 /**
  * Sends a prepared request and returns the respective response.
  *
  * @param \TYPO3\Flow\Http\Request $request
  * @return \TYPO3\Flow\Http\Response
  * @api
  */
 public function sendRequest(Request $request)
 {
     foreach ($this->automaticRequestHeaders->getAll() as $name => $values) {
         $request->setHeader($name, $values);
     }
     $this->lastRequest = $request;
     $this->lastResponse = $this->requestEngine->sendRequest($request);
     return $this->lastResponse;
 }
 /**
  * @param string $resource
  * @param array $requestArguments
  * @param string $method
  * @return mixed
  * @throws OAuth2Exception
  */
 public function query($resource, $requestArguments = array(), $method = 'GET')
 {
     $requestArguments['access_token'] = $this->currentAccessToken;
     $requestArguments['sig'] = $this->generate_sig($resource, $requestArguments);
     // test the secure API call by getting information of the own user - scope: basic (also available in sandbox mode)
     $request = Request::create(new Uri($this->endpoint . $resource . "?" . http_build_query($requestArguments)));
     $response = $this->requestEngine->sendRequest($request);
     $responseContent = $response->getContent();
     if ($response->getStatusCode() !== 200) {
         $this->securityLogger->log('Error in Instagram Query: ' . $responseContent);
         throw new OAuth2Exception(sprintf('The response was not of type 200 but gave code and error %d "%s"', $response->getStatusCode(), $responseContent), 1455261376);
     }
     return json_decode($responseContent, true);
 }
 /**
  * Sends a prepared request and returns the respective response.
  *
  * @param \TYPO3\Flow\Http\Request $request
  * @return \TYPO3\Flow\Http\Response
  * @api
  */
 public function sendRequest(Request $request)
 {
     $this->lastRequest = $request;
     $this->lastResponse = $this->requestEngine->sendRequest($request);
     return $this->lastResponse;
 }