So I don’t hit the servers constantly I was trying to put in a way to ONLY check every 4 hours…Here is what I have…
[php]
if (time()-filemtime($myfile) > 4 * 3600) {
function get_data($url)
{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$myfile=fopen(‘channel.json’, “w”);
$api = file_get_contents(“https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=$maxVids&playlistId=$id&key=$key”);
fwrite($myfile, $api);
fclose($myfile);
}
[/php]
Problem is it’s by passing the time check and every time I reload the page it writes to the file…
suggestion?
Thanks!