Created
April 28, 2011 00:00
-
-
Save evansolomon/945513 to your computer and use it in GitHub Desktop.
French Laundry Alerts
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 | |
//number of people in the reservation | |
$people = 2; | |
//time, just the hour, pm | |
$time = 7; | |
$url = 'http://www.opentable.com/nextavailabletable.aspx?hpu=1025002033&shpu=1&rid=1180&m=4&d=8/13/2010+'.$time.':00:00+PM&p='.$people; | |
$data = file_get_contents($url); | |
$regex = '/\[\'\d{1,2}\/\d{1,2}\/\d{4} \d{1,2}\:\d{2}\:\d{2} PM/'; | |
preg_match_all($regex,$data,$output); | |
$times = array(); | |
for($i=0;$output[0][$i];$i++){ | |
$times[]=str_replace("['","",$output[0][$i]); | |
} | |
$body=''; | |
if(count($times)>0){ | |
$to = '[email protected]'; | |
for($i=0;$times[$i];$i++){ | |
$body .= $times[$i] . "\n"; | |
} | |
$body .= "\n" . $url; | |
$subject = "French Laundry Alert"; | |
$headers = 'From: [email protected]' . "\r\n" . | |
'Reply-To: [email protected]' . "\r\n"; | |
mail($to, $subject, $body, $headers); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment