duangang2825
2018-05-23 14:24循环一个file_get_contents直到在php中获得非空的JSON
I have the following code:
<?php
$json = file_get_contents("https://api.nanopool.org/v1/eth/payments/0x218494b2284a5f165ff30d097d3d7a542ff0023B");
$decode = json_decode($json,true);
foreach($decode['data'] as $val){
echo date('Y-m-d',$val['date']).' -- '.$val['amount'].' -- '.$val['txHash'].' -- '.$val['confirmed'];
echo "<br/>";
}
The API used (nanopool) being extremely unreliable, I get a non empty json (success) every 2 to 10 calls.
I tried to loop the file_get_contents (do... while) until getting a non empty json without success. What can you recommend to loop until I get an answer?
- 点赞
- 回答
- 收藏
- 复制链接分享
1条回答
为你推荐
- 循环一个file_get_contents直到在php中获得非空的JSON
- loops
- php
- 1个回答
- 你能做一个$ json = file_get_contents($ url); 在已使用$ json = file_get_contents($ url);的foreach语句中? [关闭]
- foreach
- php
- 2个回答
- Apache服务器中未定义File_get_contents错误
- json
- apache
- php
- 1个回答
- file_get_contents或从Controller读取JSON文件
- json
- php
- 1个回答
- 为什么php的file_get_contents错误地从xkcd中检索json文件?
- json
- http-headers
- php
- 2个回答
换一换