如何修复警告:file_get_contents()无法在PHP中打开流

时间:2015-06-01 10:48:10

标签: php ooyala

我正在尝试解析Ooyala网址中的JSON数据,但我遇到了错误。

示例生成的网址:

https://api.ooyala.com/v2/analytics/reports/account/performance/total/2015-01-01...2015-01-10?api_key=U3dms60g81_FPxszqQDbACnZsC_J.6so11&expires=1434366377&signature=NnE%2F6vsYOEJsrJ3yYEmO%2BXVXnr4d7ljDc8%2BvFNCkywo

示例回复:

  

{"结果":[{" ID":"总""度量" {"视频&#34 ;:{"显示器":90847" uniq_displays" {" daily_uniqs":42819" weekly_uniqs":32512" monthly_uniqs":31838},"播放":27941" uniq_plays" {" daily_uniqs":21075" weekly_uniqs":17949 " monthly_uniqs":17679},"重放":1460," uniq_replays" {" daily_uniqs":1101," weekly_uniqs& #34;:1075," monthly_uniqs":1075}," time_watched":4850762080," playthrough_25":23086" playthrough_50":21306 " playthrough_75":20013" playthrough_100":16900" player_loads":90688" uniq_player_loads" {" daily_uniqs&# 34;:42899" weekly_uniqs":32565" monthly_uniqs":31886}," video_bytes_downloaded":"该   度量已经   。弃用#&34;," initial_plays":27597" video_starts":27811" uniq_video_starts" {" daily_uniqs":20992, " weekly_uniqs":17878" monthly_uniqs":17609}}}}]}

这是错误:

Warning: file_get_contents(<my URL here>): failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\xampp\htdocs\Ooyala\GetURL.php on line 84

Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\Ooyala\GetURL.php on line 84

Code I尝试运行:

$content = file_get_contents($url);
$json = json_decode($content, true);

ini_set('max_execution_time', 360);
foreach($json['results']['metrics']['video'] as $item)
{
    echo $item['playthrough_50'];
    echo '<br>';
    echo $item['video_starts'];
}

我的网络选项中有自动配置脚本。它是否会影响使用file_get_contents()函数?

0 个答案:

没有答案