$client = new \Stevenmaguire\Yelp\v2\Client(array(
'consumerKey' => 'YOUR COSUMER KEY',
'consumerSecret' => 'YOUR CONSUMER SECRET',
'token' => 'YOUR TOKEN',
'tokenSecret' => 'YOUR TOKEN SECRET',
'apiHost' => 'api.yelp.com' // Optional, default 'api.yelp.com'
));
$results = $client->search(array('term' => 'Sushi', 'location' => 'Chicago, IL'));
$results = $client->searchByPhone(array('phone' => '867-5309'));
$business = $client->getBusiness('union-chicago-3');
You may include action links in your results by passing additional parameters with your request.
$resultsWithActionLinks = $client->getBusiness('union-chicago-3', [
'actionLinks' => true
]);
$client->setDefaultLocation('Chicago, IL') // default location for all searches if location not provided
->setDefaultTerm('Sushi') // default keyword for all searches if term not provided
->setSearchLimit(20); // number of records to return
If the API request results in an Http error, the client will throw a \Stevenmaguire\Yelp\Exception\HttpException
that includes the response body, as a string, from the Yelp API.
try {
$business = $client->getBusiness('union-chicago-3');
} catch (\Stevenmaguire\Yelp\Exception\HttpException $e) {
$responseBody = $e->getResponseBody(); // string from Http request
$responseBodyObject = json_decode($responseBody);
}