Skip to content

Gerfaut/yelpv3-php

 
 

Repository files navigation

DEPRECATED - Yelp PHP Client

DEPRECATED

The base project of this fork is now officially supporting YELP V3 Fusion : https://github.com/stevenmaguire/yelp-php.

Use that one instead.


Latest Version Software License Build Status Coverage Status Quality Score Total Downloads

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

License

The MIT License (MIT). Please see License File for more information.

About

DEPRECATED - A php client for consuming Yelp API v3 (Fusion)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%