PHP code example of darkling / php-zomato-client
1. Go to this page and download the library: Download darkling/php-zomato-client 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/ */
darkling / php-zomato-client example snippets
// Create request
$request = new RestaurantRequest(16506740); // restaurant ID
// OR
//$request = RestaurantRequest::createFromParameters(['res_id' => 16506740]);
// Name of parameters must respect name of parameters in zomato api documentation
// Create client
// You can choose from three possible output options (JSON_STRING, JSON_ARRAY, JSON_STD_CLASS)
$client = new ZomatoClient('userApiKey', ResponseOption::get(ResponseOption::JSON_STRING));
// Send request and get response
$response = $client->send($request);
// Handle response
if ($response->isOk()) {
var_dump($response->getData());
} else {
var_dump($response->getStatusCode());
var_dump($response->getReasonPhrase());
}