Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <head>
- <title>Which Apple Store is the busiest? todo: lookup table of logo graphics sortable table.</title>
- <link rel="import" href="statcounter-include.html">
- <!--Start of Zopim Live Chat Script-->
- <script type="text/javascript">
- window.$zopim||(function(d,s){var z=$zopim=function(c){z._.push(c)},$=z.s=
- d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set.
- _.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute("charset","utf-8");
- $.src="//v2.zopim.com/?3OEmwjPqSV4goKBnrct9k32AQkWeres8";z.t=+new Date;$.
- type="text/javascript";e.parentNode.insertBefore($,e)})(document,"script");
- </script>
- <!--End of Zopim Live Chat Script-->
- <script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.11.3.min.js"></script>
- <script type="text/javascript" language="javascript" src="https://cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js"></script>
- <style type="text/css">
- /* Define the background color for all the ODD background rows */
- #busiest tr:nth-child(odd){
- background: #b8d1f3;
- }
- /* Define the background color for all the EVEN background rows */
- #busiest tr:nth-child(even){
- background: #dae5f4;
- }
- tfoot input {
- width: 100%;
- padding: 3px;
- box-sizing: border-box;
- }
- </style>
- <script type="text/javascript" class="init">
- $(document).ready(function() {
- $('#busiest').DataTable( {
- columnDefs: [ {
- targets: [ 3 ],
- orderData: [ 1, 0 ]
- }, {
- targets: [ 4 ],
- orderData: [ 1, 0 ]
- } ]
- } );
- } );
- </script>
- </head>
- <body>
- <div name="4sqfeed" style="border:red 2px solid; width:100%;">
- <?php
- //see geocoder.us, mygeoposition.com
- //-6.214239,106.80723 = Indonesia
- //New York: 40.755932,-73.986508
- $formsubm = $_REQUEST['formsubm'];
- //http://www.webmasterworld.com/forum88/9375.htm
- //http://geocoder.us/help/city_state_zip.shtml
- //http://geocoder.us/service/csv/geocode?zip=95472
- if(!isset($formsubm))
- {
- $latlon = "40.755932,-73.986508";
- $place = "Apple Store";
- }
- else
- {
- $latlon = $_REQUEST['latlon'];
- $place = $_REQUEST['placename'];
- }
- if ($latlon =="40.755932,-73.986508") $locname="New York";
- if ($latlon =="42.348522,-71.082229") $locname="Boston";
- if ($latlon =="41.894786,-87.623949") $locname="Chicago";
- if ($latlon =="29.739134,-95.464410") $locname="Houston";
- if ($latlon =="37.785840,-122.406100") $locname="San Francisco";
- ?>
- <h2>Which <<u><?= $place; ?></u>> is the busiest in <<u><?= $locname; ?></u>></h2>
- <h4>What is it?</h4>
- <p align=justify>I am using the FOURSQUARE REST API/JSON based output by registering this as a REST app with Foursquare developer program. I am also using CSS, HTML5, embedded PHP in HTML,OAuth2 based flow authentication, geocoding, I am using Foursquare's v2/venues/search which can be viewed https://developer.foursquare.com/overview/venues
- </p>
- <p align=justify>
- Geocoding is the process of converting addresses (like "1600 Amphitheatre Parkway, Mountain View, CA") into geographic coordinates (like latitude 37.423021 and longitude -122.083739), which you can use to place markers on a map, or position the map. One could use Google Maps Geocoding API, but I am using a more simpler geocoding: Since physical place names are made by God to remain in the same latitude/longitude, I found the lat/lon of popular cities in the US such as N.Y., Boston, Chicago, Houston and San Francisco. These lat/lon are hardcoded into this simple one-page app for simplicity sake. Example, New York is always at lat/lon 40.755932,-73.986508 and wont change. The PHP form does self-submit.
- </p>
- <img src="https://ss0.4sqi.net/img/poweredByFoursquare/poweredby-full-color-bf549c16c0ab3e1b04706ab5fcb422f1.png"/>
- <br/>
- <form method="post">
- Place:
- <select name="placename">
- <option value="Apple Store" <?= ($place=="Apple Store") ? "SELECTED" : ""; ?>>Apple Store</option>
- <option value="Macys" <?= ($place=="Macys") ? "SELECTED" : ""; ?>>Macys</option>
- <option value="Walgreens" <?= ($place=="Walgreens") ? "SELECTED" : ""; ?>>Walgreens</option>
- <option value="KFC" <?= ($place=="KFC") ? "SELECTED" : ""; ?>>KFC</option>
- <option value="Trader Joes" <?= ($place=="Trader Joes") ? "SELECTED" : ""; ?>>Trader Joes</option>
- <option value="Taco Bell" <?= ($place=="Taco Bell") ? "SELECTED" : ""; ?>>Taco Bell</option>
- <option value="McDonalds" <?= ($place=="McDonalds") ? "SELECTED" : ""; ?>>McDonalds</option>
- <option value="Starbucks" <?= ($place=="Starbucks") ? "SELECTED" : ""; ?>>Starbucks</option>
- </select>
- <select name="latlon">
- <option value="40.755932,-73.986508" <?= ($latlon=="40.755932,-73.986508") ? "SELECTED" : ""; ?>>New York</option>
- <option value="42.348522,-71.082229" <?= ($latlon=="42.348522,-71.082229") ? "SELECTED" : ""; ?>>Boston</option>
- <option value="41.894786,-87.623949" <?= ($latlon=="41.894786,-87.623949") ? "SELECTED" : ""; ?>>Chicago</option>
- <option value="29.739134,-95.464410" <?= ($latlon=="29.739134,-95.464410") ? "SELECTED" : ""; ?>>Houston</option>
- <option value="37.785840,-122.406100" <?= ($latlon=="37.785840,-122.406100") ? "SELECTED" : ""; ?>>San Francisco</option>
- </select>
- <input type=hidden name="formsubm" value="1"/>
- <input type=submit name="submit" value="Submit">
- </form>
- <br/><br/>
- checkinsCount = (total checkins ever)
- <br/>
- usersCount = (total users who have ever checked in here).
- <br/>
- hereNow = (users checked in now)
- <br/>
- <?php
- $place_e = urlencode($place);
- $url = "https://api.foursquare.com/v2/venues/search?ll=" . $latlon . "&limit=50&v=20131119&query=$place_e&client_id=V0TPGR31B3YQXZAV3JHADOACZJPCFC2NN1JM5X3VPYI4B1K1&client_secret=3ZOSDOEY5SABBP14O45G4UQMA1JSFS4LC0LDH3C5ZI1A35MF";
- if ( $url ) {
- $json = file_get_contents( $url );
- $data = json_decode($json);
- //var_dump($data);
- //asort($data,);
- //print_r($my_array);
- echo "<p>Show 50 entries! This system is designed to return 50 entries</p>";
- echo "<p>(you could) start typing in your ZIP in the Search: below.</p>";
- echo "<table class=\"TFTable\" id=\"busiest\" name=\"busiest\" width=\"100%\" border=1 style=\"border:black 3px solid;\"><thead><tr><th colspan=\"6\" align=\"center\">$place - $locname Latlon: $latlon <b>(10000m radius)</b><br>Picture: <img src=\"images/$place.jpg\" width=70 height=70></th></tr><tr><th>Place Name</th><th>Physical Address</th><th>Checkins Count (SORTBY click here)</th><th>Users Count (SORTBY click here)</th><th>hereNow count (SORTBY click here)</th></thead><tfoot><tr><td><td><td><td><td></tfoot><tbody></tr>";
- foreach ($data->response->venues as $result) {
- echo "<tr>";
- echo "<td>" . $result->name;
- echo "<td nowrap>" . $result->location->address . "," . $result->location->crossStreet . "," . $result->location->city . "," . $result->location->state . " " . $result->location->postalCode . "</td>";
- echo "<td align=right>" . $result->stats->checkinsCount . "</td>";
- echo "<td align=right>" . $result->stats->usersCount . "</td>";
- echo "<td align=right>" . $result->hereNow->count . "</td>";
- echo "</tr>\n\n";
- }
- echo "</tbody></table>";
- }
- ?>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement