The base project of this fork is now officially supporting YELP V3 Fusion : https://github.com/stevenmaguire/yelp-php.
Use that one instead.
A PHP client for authenticating with Yelp using OAuth2 and consuming the Fusion API (v3).
More information about Yelp Fusion (v3) API.
Via Composer
$ composer require gerfaut/yelpv3-php
$client = new Gerfaut\Yelp\Client(array(
'consumerKey' => 'YOUR COSUMER KEY',
'consumerSecret' => 'YOUR CONSUMER SECRET',
'apiHost' => 'api.yelp.com' // Optional, default 'api.yelp.com'
));
Yelp documentation and available parameters : https://www.yelp.com/developers/documentation/v3/business_search
$results = $client->search(array('term' => 'Sushi', 'location' => 'Chicago, IL'));
Yelp documentation : https://www.yelp.com/developers/documentation/v3/business_search_phone
$results = $client->searchByPhone(array('phone' => '867-5309'));
Yelp documentation : https://www.yelp.com/developers/documentation/v3/business
$results = $client->getBusiness('union-chicago-3');
Yelp documentation : https://www.yelp.com/developers/documentation/v3/business_reviews
$results = $client->getReviews('union-chicago-3');
Yelp documentation : https://www.yelp.com/developers/documentation/v3/autocomplete
$results = $client->getAutocompleteSuggestions(array('text' => 'park', 'latitude' => 37.786942, 'longitude' => -122.399643));
Yelp documentation : https://www.yelp.com/developers/documentation/v3/transactions_search
$results = $client->getTransactions(array('transaction_type' => 'delivery', 'latitude' => 37.786942, 'longitude' => -122.399643));
Currently 'delivery' is the only transaction type supported by Yelp and is the default value.
$results = $client->getTransactions(array('latitude' => 37.786942, 'longitude' => -122.399643));
$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 Gerfaut\Yelp\Exception\ApiException
that includes the response body, as a string, from the Yelp API.
If the Deserialization process results in an error, the client will throw a Gerfaut\Yelp\Exception\DeserializeException
that includes the Exception from JMS\Serialize librabry.
$responseBody = $e->getResponseBody(); // string from Http request
$responseBodyObject = json_decode($responseBody);
Using your global phpunit install:
$ phpunit
Or using the vendors (from the root folder):
$ ./vendor/phpunit/phpunit/phpunit
Please see CONTRIBUTING for details.
- Christophe Leemans
- Steven Maguire for his v2 library
- compworkmail for his very nice start of v3 implementation
- All Contributors
The MIT License (MIT). Please see License File for more information.