Created
February 13, 2013 05:30
-
-
Save tylerhall/4942502 to your computer and use it in GitHub Desktop.
Get ready for WWDC.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?PHP | |
$html = file_get_contents('https://developer.apple.com/wwdc/'); | |
if($html === false) | |
{ | |
send_script_failure(); | |
exit; | |
} | |
preg_match_all('/2012/', $html, $mentions2012); | |
preg_match_all('/2013/', $html, $mentions2013); | |
$mentions2012 = count($mentions2012[0]); | |
$mentions2013 = count($mentions2013[0]); | |
if(($mentions2012 != 3) || ($mentions2013 != 1)) | |
{ | |
send_message(); | |
} | |
else | |
{ | |
echo "Everything's fine.\n"; | |
} | |
function send_message() | |
{ | |
for($i = 0; $i < 5; $i++) | |
{ | |
curl_setopt_array($ch = curl_init(), array( | |
CURLOPT_URL => "https://api.pushover.net/1/messages.json", | |
CURLOPT_POSTFIELDS => array( | |
"token" => "<token>", | |
"user" => "<user>", | |
"message" => "WWDC tickets might be on sale!", | |
"sound" => "siren", | |
))); | |
curl_exec($ch); | |
curl_close($ch); | |
sleep(5); | |
} | |
} | |
function send_script_failure() | |
{ | |
curl_setopt_array($ch = curl_init(), array( | |
CURLOPT_URL => "https://api.pushover.net/1/messages.json", | |
CURLOPT_POSTFIELDS => array( | |
"token" => "<token>", | |
"user" => "<user>", | |
"message" => "WWDC script failed.", | |
))); | |
curl_exec($ch); | |
curl_close($ch); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@bradchoate Nice call on checking for the image filename.