Browse files

Merge branch 'master' of https://github.com/CodeforOakland/510eat

  • Loading branch information...
2 parents 09471cc + 29728a4 commit 8b5abc903453dc88111ac8854514e189471eee41 @kamron kamron committed Jul 21, 2012
Showing with 127 additions and 0 deletions.
  1. +56 −0 FiveOneOhEats.class.php
  2. +2 −0 README
  3. +69 −0 query.php
View
56 FiveOneOhEats.class.php
@@ -0,0 +1,56 @@
+<?php
+if (!class_exists('FiveOneOhEats')) {
+
+ class FiveOneOhEats {
+ const VERSON = '1.0';
+
+
+
+ function get_results($query, $street_name){
+ $json = $fiveoneoheats->do_curl_get_https("https://data.acgov.org/api/views/3d5b-2rnz/rows.json?search=burger&max_rows=25", $headers, $returnxfer = true);
+ $result_data = json_decode($json);
+ $result = array();
+ foreach ( $result_data->data as $row ) {
+ if(preg_match('/'.$street_name.'/i', $row[12][0])){
+ {
+ $result_line = array($row[8],$row[11]);
+ array_push($result,$result_line);
+ }
+ }
+ return $result;
+ }
+
+ function do_curl_get_https($https_url, $headers) {
+
+ //open connection
+ $ch = curl_init();
+
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+ curl_setopt($ch, CURLOPT_CAINFO, NULL);
+ curl_setopt($ch, CURLOPT_CAPATH, NULL);
+
+ //set the url, number of POST vars, POST data
+ curl_setopt($ch, CURLOPT_URL, $https_url);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+
+ //execute post
+ $result_json = curl_exec($ch);
+
+ curl_close($ch);
+
+ return $result_json;
+
+ }
+
+
+ }
+
+
+ }
+
+ global $fiveoneoheats;
+ $fiveoneoheats = new FiveOneOhEats();
+}
+?>
View
2 README
@@ -0,0 +1,2 @@
+a
+
View
69 query.php
@@ -0,0 +1,69 @@
+<?php
+
+/*
+ * Created on Jul 21, 2012
+ *
+ * To change the template for this generated file go to
+ * Window - Preferences - PHPeclipse - PHP - Code Templates
+ */
+
+ function get_results($query, $street_name){
+ $json = do_curl_get_https("https://data.acgov.org/api/views/3d5b-2rnz/rows.json?search=burger&max_rows=25", $headers, $returnxfer = true);
+ $result_data = json_decode($json);
+ //print_r($result_data);
+ $result = array();
+ foreach ( $result_data->data as $row ) {
+
+ $row_decoded = json_decode($row[12][0]);
+ $search = sprintf("/%s/i",$street_name);
+
+ $matched = preg_match($search, $row_decoded->address);
+
+ //$matched = preg_match("/niles/i", $row[12][0]);
+
+ if($matched){
+ //print_r($row_decoded->address);
+ $result_line = array($row[11],$row[9],$row_decoded);
+ array_push($result,$result_line);
+ }
+ //{
+ //print_r($row_decoded);
+ //$result_line = array($row[8],$row[11]);
+ //array_push($result,$result_line);
+ //}
+ }
+ return $result;
+ }
+
+ function do_curl_get_https($https_url, $headers) {
+
+ //open connection
+ $ch = curl_init();
+
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+ curl_setopt($ch, CURLOPT_CAINFO, NULL);
+ curl_setopt($ch, CURLOPT_CAPATH, NULL);
+
+ //set the url, number of POST vars, POST data
+ curl_setopt($ch, CURLOPT_URL, $https_url);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+
+ //execute post
+ $result_json = curl_exec($ch);
+
+ curl_close($ch);
+
+ return $result_json;
+
+ }
+
+
+?>
+<pre>
+<?php
+ $result = get_results('burger', 'ALVARADO NILE');
+ print_r($result);
+?>
+</pre>

0 comments on commit 8b5abc9

Please sign in to comment.