我正在使用cURL从Unocoing的这个链接获取数据 - https://www.unocoin.com/trade?all
function api_price($api_url){
if(!empty($api_url)){
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $api_url,
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);
return $response;
curl_close($curl);
}
}
if(!empty($_GET['url'])){
$api_url=$_GET['url'];
$tag=$_GET['tag'];
$api_price=api_price($api_url);
$response = json_decode($api_price, true);
$output= $response[$tag];
echo $output['lastPrice'];
}
我在其他交易所使用相同的代码。但有些像unocoin,coindelta显示bool(假) https://coindelta.com/api/v1/public/getticker/