File_get_contents does not return any data

So, I use the Football League API, I returned the data that I need. However, now it stops working suddenly, and I'm not sure why.

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);

If I exit $this->baseUri . $resource, I get a working link so why can't file_contents get the contents?

See also page here.

+4
source share
2 answers

Well, I made it to be

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

And it brought me all the disaster, as you expect. Not sure if this will help you.

+1
source

Perhaps the administrator has disabled the function (file_get_contents) in the php.ini file? You should print your php information page and study it.

0
source

Source: https://habr.com/ru/post/1661394/


All Articles