Skip to content

Instantly share code, notes, and snippets.

@rallat
Forked from evansolomon/gist:945513
Created May 12, 2014 22:06
Show Gist options
  • Save rallat/2a196edf7186356ff84b to your computer and use it in GitHub Desktop.
Save rallat/2a196edf7186356ff84b to your computer and use it in GitHub Desktop.
<?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