/**
  * Execute the Instagram Request
  *
  * @param void
  *
  * @throws InstagramResponseException
  *
  * @return InstagramResponse
  */
 protected function execute()
 {
     $authMethod = '?access_token=' . $this->params['access_token'];
     $endpoint = Constants::API_VERSION . $this->path . ('GET' === $this->method ? '?' . http_build_query($this->params) : $authMethod);
     $endpoint .= (strstr($endpoint, '?') ? '&' : '?') . 'sig=' . static::generateSignature($this->instagram->getApp(), $this->path, $this->params);
     $request = HelperFactory::getInstance()->request($this->instagram->getHttpClient(), $endpoint, $this->params, $this->method);
     if ($request === null) {
         throw new InstagramResponseException('400 Bad Request: instanceof InstagramResponse cannot be null', 400);
     }
     $this->response = new InstagramResponse($request);
     $this->xRateLimitRemaining = $this->response->getHeader('X-Ratelimit-Remaining');
 }
 /**
  * Get the Oauth Access Token of a user from callback code
  *
  * @param string $code - Oauth2 Code returned with callback url after successfull login
  *
  * @return InstagramOAuth
  */
 public function oauth($code)
 {
     $options = ['grant_type' => 'authorization_code', 'client_id' => $this->app->getId(), 'client_secret' => $this->app->getSecret(), 'redirect_uri' => $this->getCallbackUrl(), 'code' => $code, 'state' => $this->state];
     $response = HelperFactory::getInstance()->request($this->client, Constants::API_TOKEN, $options, 'POST');
     $this->oauthResponse = new InstagramOAuth(json_decode($response->getBody()->getContents()));
     return $this->oauthResponse;
 }