function getEPGData($providerId) { global $baseTime, $daysRequested, $config; $cacheFile = "./cache/{$providerId}.cache"; chdir($config['localDir']); if (!isExpired($cacheFile)) { $fp = fopen($cacheFile, 'r') or die("Can't open provider cache file for reading."); $serializedResponse = ""; while (!feof($fp)) { $serializedResponse .= fread($fp, 8192); } fclose($fp); $response = unserialize($serializedResponse); return $response; } $username = $config['sd_access'][$providerId]['username']; $password = $config['sd_access'][$providerId]['password']; $client = new SoapClient("http://docs.tms.tribune.com/tech/tmsdatadirect/schedulesdirect/tvDataDelivery.wsdl", array('login' => $username, 'password' => $password, 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_DEFLATE)); if (!isset($daysRequested)) { $daysRequested = 8; } if (isset($config['numDaysEPG'])) { $daysRequested = $config['numDaysEPG']; } if (isset($config['providers'][$providerId]['numDaysEPG'])) { $daysRequested = $config['providers'][$providerId]['numDaysEPG']; } $startTime = gmstrftime("%Y-%m-%dT00:00:00Z", $baseTime); $endTime = gmstrftime("%Y-%m-%dT00:00:00Z", strtotime("+{$daysRequested} days", time())); $response = $client->download($startTime, $endTime); $fp = fopen("./cache/" . $providerId . '.cache', 'w') or die("Can't open provider cache file for writing."); fwrite($fp, serialize($response)); fclose($fp); return $response; }