Skip to content

hoseinrafiei/easy-yelp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Easy Yelp API Integration

Easy Yelp is a single file PHP client for Yelp API.

Installation

You can simply install it using composer.

composer require hoseinrafiei/easy-yelp

If you're not using composer, you can simply download the file and include it in your project manually.

require 'yelp.php';

Usage

Create an instance and send your API token to the constructor method. Then simply call the methods with proper request and fetch the data from Yelp API Easily.

$yelp = new EasyYelp\Yelp('YOUR_API_TOKEN');
$businesses = $yelp->businessSearch([
    'location' => 'Los Angeles, CA',
    'price' => '1,2,3',
    'sort_by' => 'distance',
    'limit' => '30',
])->getArray();

Methods

$request = [];
$yelp->businessSearch($request)->getArray();
$request = [];
$yelp->businessPhoneSearch($request)->getArray();
$request = [];
$yelp->transactionSearch('delivery', $request)->getArray();
$businessId = 'blahblah'; 
$request = [];
$yelp->businessDetails($businessId, $request)->getArray();
$request = [];
$yelp->businessMatch($request)->getArray();
$businessId = 'blahblah';
$request = [];
$yelp->businessReviews($businessId, $request)->getArray();
$request = [];
$yelp->autocomplete($request)->getArray();
$eventId = 'blahblah';
$request = [];
$yelp->eventDetails($eventId, $request)->getArray();
$request = [];
$yelp->events($request)->getArray();
$request = [];
$yelp->featuredEvent($request)->getArray();
$request = [];
$yelp->categories($request)->getArray();
$alias = 'blahblah'; 
$request = [];
$yelp->categoryDetails($alias, $request)->getArray();

Examples

You can check examples directory files to see some examples for using API methods.

Errors

To check if you received an error from Yelp API or not you can use following functions.

$businesses = $yelp->businessSearch($request)->getArray();
if($yelp->hasError()) // We have an error
{
    echo $yelp->getError(); // Print the error message
}

License

This software released under MIT License.