aboutsummaryrefslogtreecommitdiffstats
path: root/index.php
diff options
context:
space:
mode:
authorTeddy Wing2013-05-06 17:50:31 -0400
committerTeddy Wing2013-05-06 17:50:31 -0400
commit5f972b2eef0833da831216546622874150ba55f6 (patch)
tree30a8c06f510f1f6f1074961909d283b42fbcc3a4 /index.php
parentf47322366e6cfd0a1727eaf5613d601f1cc16df2 (diff)
downloadBoston-Food-Truck-Schedule-API-5f972b2eef0833da831216546622874150ba55f6.tar.bz2
Extract food truck code into a separate class
The schedule() method in that class also includes a bunch of my failed attempts at filtering. Will update with a cleaner method of filtering.
Diffstat (limited to 'index.php')
-rw-r--r--index.php59
1 files changed, 10 insertions, 49 deletions
diff --git a/index.php b/index.php
index ef5fc76..c16c5c9 100644
--- a/index.php
+++ b/index.php
@@ -1,56 +1,17 @@
<?php
-error_reporting(0);
+// error_reporting(0);
-$food_truck_html = file_get_contents('http://www.cityofboston.gov/business/mobile/schedule-app.asp?v=1&71');
+require_once('boston_food_trucks.php');
-$dom = new DOMDocument;
-$dom->loadHTML($food_truck_html);
-$finder = new DomXPath($dom);
+$BostonFoodTrucks = new BostonFoodTrucks;
-$class_company = 'com';
-$class_day_of_the_week = 'dow';
-$class_time_of_day = 'tod';
-$class_location = 'loc';
-$companies = $finder->query('//td[@class="' . $class_company . '"]/a/text()');
-$company_urls = $finder->query('//td[@class="' . $class_company . '"]/a/@href');
-$days_of_week = $finder->query('//td[@class="' . $class_day_of_the_week . '"]/text()');
-$times_of_day = $finder->query('//td[@class="' . $class_time_of_day . '"]/text()');
-$locations = $finder->query('//td[@class="' . $class_location . '"]/text()');
+//echo $BostonFoodTrucks->schedule();
+//echo $BostonFoodTrucks->trucks_now();
-echo var_dump($locations->item(0)->nodeValue);
-echo ' :: ';
-echo $locations->length;
-
-echo ' :: ';
-echo date('l');
-
-echo ' :: ';
-
-$today_as_string = date('l');
-$time_of_day_filter = 'Lunch';
-$locations_filter = array();
-
-$todays_lunch_food_trucks = array(
- 'food_trucks' => array()
-);
-
-for ($i = 0; $i < $locations->length; $i++) {
- if ($days_of_week->item($i)->nodeValue == $today_as_string) {
- if ($times_of_day->item($i)->nodeValue == $time_of_day_filter) {
- echo '<p><a href="' . $company_urls->item($i)->nodeValue. '">' . $companies->item($i)->nodeValue . '</a></p>';
-
- array_push($todays_lunch_food_trucks['food_trucks'], array(
- 'company' => $companies->item($i)->nodeValue,
- 'company_url' => $company_urls->item($i)->nodeValue,
- 'day_of_week' => $today_as_string,
- 'time_of_day' => $time_of_day_filter,
- 'location' => $locations->item($i)->nodeValue
- ));
- }
- }
-}
-
-echo json_encode($todays_lunch_food_trucks);
-# echo $food_truck_html;
+echo $BostonFoodTrucks->schedule(array(
+ 'days_of_week' => array(date('l')),
+ 'times_of_day' => array('Lunch'),
+ 'locations' => $BostonFoodTrucks->locations_downtown
+)); \ No newline at end of file