Skip to content

Instantly share code, notes, and snippets.

@anta40
Last active October 31, 2020 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anta40/99f36e3ce947a9a09794ff0dc7a3fec1 to your computer and use it in GitHub Desktop.
Save anta40/99f36e3ce947a9a09794ff0dc7a3fec1 to your computer and use it in GitHub Desktop.
<?php
/*
Curl command:
curl -X GET --header "Accept: application/json" --header "user-key: xxxxxxxxxxxxxxxxxxxx" "https://developers.zomato.com/api/v2.1/search?entity_id=74&q=seafood"
*/
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$ZOMATO_API_KEY = "xxxxxxxxxxxxxxxx";
$BASE_URL = "https://developers.zomato.com/api/v2.1/search";
// Find all 'seafood' restaurants in Jakarta
$data = array ('entity_id' => '47', 'q' => 'seafood');
$PARAMS = '';
foreach ($data as $key=>$value){
$PARAMS .= $key.'='.$value.'&';
}
$PARAMS = trim($PARAMS, '&');
$HEADERS = [
'Accept' => 'application/json',
'user-key' => $ZOMATO_API_KEY
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $BASE_URL.'?'.$PARAMS);
curl_setopt($ch, CURLOPT_HTTPHEADER, $HEADERS);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$curl_output = curl_exec($ch);
curl_close($ch);
echo $curl_output;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment