PHP code example of tims / zomato-php-sdk

1. Go to this page and download the library: Download tims/zomato-php-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tims / zomato-php-sdk example snippets


use Tims\Zomato\ZomatoClient;

$zomato = new ZomatoClient(getenv('ZOMATO_USER_KEY'));

use Tims\Zomato\Enums\EntityType;
use Tims\Zomato\Enums\Sort;
use Tims\Zomato\ZomatoClient;

$zomato = new ZomatoClient($userKey);

$categories = $zomato->categories();
$cities = $zomato->cities(['q' => 'Mumbai', 'count' => 5]);

$results = $zomato->search([
    'entity_id' => 1,
    'entity_type' => EntityType::City,
    'q' => 'pizza',
    'cuisines' => [25, 55],
    'sort' => Sort::Rating,
    'count' => 20,
]);

$zomato = new ZomatoClient(
    userKey: $userKey,
    baseUrl: 'https://developers.zomato.com/api/v2.1',
);

use Tims\Zomato\ApiException;
use Tims\Zomato\ZomatoClient;

try {
    $data = (new ZomatoClient($userKey))->restaurant(16506740);
} catch (ApiException $e) {
    $e->getStatusCode();      // HTTP status
    $e->getResponseBody();    // raw body
    $e->getResponseHeaders(); // response headers
    $e->getMessage();
}

use Tims\Zomato\Enums\EntityType;
use Tims\Zomato\Enums\Order;
use Tims\Zomato\Enums\Sort;

EntityType::City;
Sort::Rating;
Order::Desc;
bash
composer 
bash
export ZOMATO_USER_KEY=your_key
php examples/categories.php