所以我正在使用足球联赛API,我让它返回我需要的数据.然而,它现在突然停止工作,我不知道为什么.
class leagueTable {
public $data;
public $baseUri;
public $config;
public $tr;
public function __construct($payload) {
$this->data = $payload;
$this->config = parse_ini_file('config.ini', true);
$this->baseUri = $this->config['baseUri'];
$this->writeTable();
}
public function writeTable() {
$resource = 'soccerseasons/' . $this->data . '/leagueTable';
$response = file_get_contents($this->baseUri . $resource, false, stream_context_create($this->reqPrefs));
if ($response == "") {
echo "Unable to retrieve data, please contact the administrator!<br />
<a target='_blank' href='".$this->baseUri.$resource."'>JSON</a>";
}
$result = json_decode($response);
如果我回应$this-> baseUri. $resource我得到一个工作link所以为什么file_get_contents不能获取内容?
最佳答案 好吧,我愚蠢到这一点
<?php
$response = file_get_contents('http://api.football-data.org/v1/soccerseasons/426/leagueTable');
$result = json_decode($response);
var_dump($result);
这让我得到了你所期待的整个灾难.
不确定这对你有什么帮助.