为什么我无法获取 zebpay Api 数据?
Why I am not able to fetch zebpay Api data?
我正在使用这些代码来获取 zebpay api 数据。
从此 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;
我也试过 file_get_contents 但同样的问题。我在另外 2 个 api 中遇到过这个问题。
注意:一旦我获得数据并正确使用它,但今天它又不能工作了。
可以直接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;
}
}
?>
我正在使用这些代码来获取 zebpay api 数据。 从此 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;
我也试过 file_get_contents 但同样的问题。我在另外 2 个 api 中遇到过这个问题。 注意:一旦我获得数据并正确使用它,但今天它又不能工作了。
可以直接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;
}
}
?>