私はサッカーリーグのAPIを使用していますので、必要なデータが返されました。しかし、それは今、突然すべての作業を停止し、なぜわからないのですか?file_get_contentsにはデータが返されません
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
をエコーした場合のfile_get_contentsは内容を取得することはできませんなぜ私は働いlinkを取得しますか?
stream_contextの目的は何ですか?あなたのサンプルコードでは、 '$ this-> reqPrefs'はnullなので、重複しているようです。また、 'ini_get( 'allow_url_fopen')の値が1であることを確認してください。 –