Last active
October 31, 2020 14:39
-
-
Save anta40/99f36e3ce947a9a09794ff0dc7a3fec1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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