A PHP client for authenticating with Yelp using OAuth 1 and consuming the search API.
Via Composer
$ composer require stevenmaguire/yelp-php
$client = new Stevenmaguire\Yelp\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'));
$results = $client->getBusiness('union-chicago-3');
$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
that includes the response body, as a string, from the Yelp API.
$responseBody = $e->getResponseBody(); // string from Http request
$responseBodyObject = json_decode($responseBody);
$ phpunit
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.