Also benutze ich eine Football Liga API, ich hatte sie die Daten zurückgeben, die ich brauchte. Jedoch hat es plötzlich aufgehört zu arbeiten und ich bin mir nicht sicher warum.file_get_contents gibt keine Daten zurück
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);
Wenn ich $this->baseUri . $resource
echo Ich werde eine Arbeits link also warum nicht file_get_contents bekommen die Inhalte?
Was ist der Zweck des stream_context? In Ihrem Beispielcode ist '$ this-> reqPrefs' null und scheint daher redundant zu sein. Überprüfen Sie auch, dass der Wert von 'ini_get ('allow_url_fopen')' ist 1. –