gerfaut / yelpv3-php
A php client for consuming Yelp API v3 (Fusion)
Installs: 3 536
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 24
Open Issues: 1
Requires
- php: >=5.4.0
- guzzlehttp/guzzle: ^6.2
- jms/serializer: ^1.4
Requires (Dev)
- mockery/mockery: ~0.9
- phpunit/phpunit: ~4.0
- squizlabs/php_codesniffer: ~2.0
This package is not auto-updated.
Last update: 2024-05-07 22:16:53 UTC
README
DEPRECATED
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.
Install
Via Composer
$ composer require gerfaut/yelpv3-php
Usage
Create client
$client = new Gerfaut\Yelp\Client(array( 'consumerKey' => 'YOUR COSUMER KEY', 'consumerSecret' => 'YOUR CONSUMER SECRET', 'apiHost' => 'api.yelp.com' // Optional, default 'api.yelp.com' ));
Search by keyword and location
Yelp documentation and available parameters : https://www.yelp.com/developers/documentation/v3/business_search
$results = $client->search(array('term' => 'Sushi', 'location' => 'Chicago, IL'));
Search by phone number
Yelp documentation : https://www.yelp.com/developers/documentation/v3/business_search_phone
$results = $client->searchByPhone(array('phone' => '867-5309'));
Locate details for a specific business by Yelp business id
Yelp documentation : https://www.yelp.com/developers/documentation/v3/business
$results = $client->getBusiness('union-chicago-3');
Get reviews for a specific business by Yelp business id
Yelp documentation : https://www.yelp.com/developers/documentation/v3/business_reviews
$results = $client->getReviews('union-chicago-3');
Retrieve autocomplete suggestions for keywords, businesses and categories, based on the input text
Yelp documentation : https://www.yelp.com/developers/documentation/v3/autocomplete
$results = $client->getAutocompleteSuggestions(array('text' => 'park', 'latitude' => 37.786942, 'longitude' => -122.399643));
Retrieve list of businesses which support certain transactions.
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));
Configure defaults
$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
Exceptions
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);
Testing
Using your global phpunit install:
$ phpunit
Or using the vendors (from the root folder):
$ ./vendor/phpunit/phpunit/phpunit
Contributing
Please see CONTRIBUTING for details.
Credits
- Christophe Leemans
- Steven Maguire for his v2 library
- compworkmail for his very nice start of v3 implementation
- All Contributors
License
The MIT License (MIT). Please see License File for more information.