/** * Execute an API call * @param string $api_method * @param string $http_method * @param array $options * @param mixed $body * @param boolean $parse * @return mixed * @throws \Exception */ public function execute($api_method, $http_method, $options = array(), $body = null, $parse = true) { if ($body !== null) { $options['body'] = $body; } // get authorization headers from oauth provider $options['headers'] = $this->client->getProvider()->getHeaders($this->client->getAccessToken()); try { $response = $this->client->getProvider()->getHttpClient()->request($http_method, $this->client->getProvider()->createUrl($api_method), $options); } catch (GuzzleException $ex) { throw new \Exception($ex->getMessage()); } if ($parse) { return $this->parse($response); } return $response; }