require_once 'TempestCache.php'; /* Two methods to retrieve tempest dataset. * Initial method is to use the API with PHP DOMDocument as fall back * if API is unreachable. * * API GET call returns a JSON dataset with current tempests. */ $API = 'http://poetempest.com/api/v1/current_tempests'; $url = 'http://poetempest.com/'; $votesRequired = '3'; $notifyTempest; $tempest = new TempestWatch($url, $votesRequired, $API); $result = $tempest->execute($notifyTempest); if (count($result) > 0 && $result != -1) { $result[] = time(); if (TempestCache::tempestChanged($result)) { //Sets Notification based on flag if (EMAIL_NOTIFICATION && SMS_NOTIFICATION) { $to = CONTACT_EMAIL . ', ' . CONTACT_SMS . '@' . CONTACT_SMS_PROVIDER; } else { if (EMAIL_NOTIFICATION) { $to = CONTACT_EMAIL; } else { if (SMS_NOTIFICATION) { $to = CONTACT_SMS . '@' . CONTACT_SMS_PROVIDER; } else { echo 'No notification set. Do nothing!'; exit; } } }