I am trying to parse JSON data from an Ooyala URL but I'm having errors.
Sample Generated URL:
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
Sample Response:
{"results":[{"id":"total","metrics":{"video":{"displays":90847,"uniq_displays":{"daily_uniqs":42819,"weekly_uniqs":32512,"monthly_uniqs":31838},"plays":27941,"uniq_plays":{"daily_uniqs":21075,"weekly_uniqs":17949,"monthly_uniqs":17679},"replays":1460,"uniq_replays":{"daily_uniqs":1101,"weekly_uniqs":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":42899,"weekly_uniqs":32565,"monthly_uniqs":31886},"video_bytes_downloaded":"This metric has been deprecated.","initial_plays":27597,"video_starts":27811,"uniq_video_starts":{"daily_uniqs":20992,"weekly_uniqs":17878,"monthly_uniqs":17609}}}}]}
Here's the error:
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'm trying to run:
$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'];
}
I have automatic configuration script in my internet options. Does it affect in using the file_get_contents() function?