これに似た投稿をいくつか検索しましたが、答えが見つかりませんでした。私はおそらく何か小さなものを見逃しています。
コードに示されているように、URLからJSONコンテンツを読み取ろうとしています。
$uri = "http://worldweatheronline.com/feed/weather.ashx?q=schruns,austria&format=json&num_of_days=5&key=8f2d1ea151085304102710";
echo "URI: [$uri] <br/>";
$file = file_get_contents($uri);
$error = error_get_last();
echo $error['message'];
ブラウザでURLを開くと、そのJSONコンテンツを確認できます。ただし、上記のコードは機能しません。$file
の値はfalse
。エラーメッセージは次のとおりです。
file_get_contents(http://worldweatheronline.com/feed/weather.ashx?q=schruns,austria&format=json&num_of_days=5&key=8f2d1ea151085304102710) [function.file-get-contents]: failed to open stream: No such file or directory.
助言がありますか?注:それが重要な場合、myallow_url_fopen
はに設定されます。1
編集:これがPHPファイル全体です。 http://pastebin.com/zCKEP9kG
また、コードにはfopen()があり、httpファイルを正常に開きます。