I am using these code to fetch zebpay api data. From this API URL - https://www.zebapi.com/api/v1/market/ticker/btc/inr
function get_api($url){
if(!empty($url)){
$api_url=$url;
if (@$_GET['curl']=="yes") {
return(header('HTTP/1.1 503 Service Temporarily Unavailable'));
} else {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$parsed_json = curl_exec($ch);
$parsed_json = json_decode($parsed_json);
return($parsed_json);
curl_close($ch);
}
}
}
$api= get_api('https://www.zebapi.com/api/v1/market/ticker/btc/inr');
echo $api->buy;
I have also try file_get_contents but same problem. I have face this issue in 2 more api's. Note: Once i get the data and use it correctly but today this is not working again.
you can call it directly by curl,
<?php
$getCurrency = "inr";
$displayArrayOutput = true;
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://www.zebapi.com/api/v1/market/ticker/btc/inr",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
if($displayArrayOutput){
$response = json_decode($response, true);
echo "<pre>";
print_r($response);
}
else{
header("Content-type:application/json");
echo $response;
}
}
?>