每隔10秒从api获取一个请求

时间:2017-11-04 20:28:22

标签: php json request limit

我一直在api上达到最大请求限制。我的页面每隔10秒刷新一次meta http-equiv="refresh" content="10"。但我知道这不是更新此数据的正确方法。我如何将此请求限制为距离源(10)的每10秒

$url = "https://api.bitfinex.com/v1/pubticker/ETHusd";    
$json = json_decode(file_get_contents($url), true);    
$eth = $json["last_price"];

1 个答案:

答案 0 :(得分:0)

您尚未解释或显示您的脚本使用$eth执行的操作但这应该有效:

$url = "https://api.bitfinex.com/v1/pubticker/ETHusd";    
while(TRUE) {
    $json = json_decode(file_get_contents($url), true);
    $eth = $json["last_price"];
    sleep(10);
}
相关问题