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); | |
} |
You can set up the same thing (a page content check) through Pingdom. They can message you through Twitter (DM if you follow their statusbot "pingdomalert") or SMS.
Pingdom documented a technique for last year's WWDC. For this year, I would recommend a check that tests for the presence of "wwdc2012-june-11-15.jpg" (the hero image shown there). If that is missing, chances are they've replaced it with the promo for 2013.
@bradchoate Nice call on checking for the image filename.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hmm. We could also test to see if the MD5() of the $html returned has changed.