php – file_get_contents没有返回任何数据

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php – file_get_contents没有返回任何数据脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
所以我正在使用足球联赛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不能获取内容

See the page here too.

解决方法

好吧,我愚蠢到这一点

<?PHP
$response = file_get_contents('http://api.football-data.org/v1/soccerseasons/426/leagueTable');
$result   = json_decode($response);
var_dump($result);

这让我得到了你所期待的整个灾难.不确定这对你有什么帮助.

脚本宝典总结

以上是脚本宝典为你收集整理的php – file_get_contents没有返回任何数据全部内容,希望文章能够帮你解决php – file_get_contents没有返回任何数据所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。