/** * Makes a request to the Yelp API and returns the response * * @param string $path The path of the APi after the domain * * @return stdClass The JSON response from the request * @throws Exception */ protected function request($path) { $url = $this->buildUnsignedUrl($this->apiHost, $path); try { $response = $this->httpClient->get($url, ['auth' => 'oauth']); } catch (ClientException $e) { $exception = new Exception($e->getMessage()); throw $exception->setResponseBody($e->getResponse()->getBody()); } return json_decode($response->getBody()); }
/** * Makes a request to the Yelp API and returns the response * * @param string $path The path of the APi after the domain * * @return stdClass The JSON response from the request * @throws Exception */ private function request($path) { $client = new HttpClient(); $oauth = new Oauth1(['consumer_key' => $this->consumer_key, 'consumer_secret' => $this->consumer_secret, 'token' => $this->token, 'token_secret' => $this->token_secret]); $client->getEmitter()->attach($oauth); $url = $this->buildUnsignedUrl($this->api_host, $path); try { $this->latest_unsigned_url = $url; $response = $client->get($url, ['auth' => 'oauth']); } catch (ClientException $e) { $exception = new Exception($e->getMessage()); throw $exception->setResponseBody($e->getResponse()->getBody()); } return json_decode($response->getBody()); }