<?php require_once 'lib/datastore.class.php'; require_once 'lib/datafetcher.class.php'; $store = new DataStore(); $fetcher = new DataFetcher(); $user = $_GET['user']; if (!$user) { die("No user specified."); } $scrobbles = $store->getAllScrobbles($user); $chart = array(); foreach ($scrobbles as $scrobble) { $address = $fetcher->fetchAddress($scrobble['latitude'] . ',' . $scrobble['longitude']); $address = preg_replace('/London.*?,/', 'London,', $address); if (!isset($chart[$address])) { $chart[$address] = array(); } if (!isset($chart[$address][$scrobble['artist']])) { $chart[$address][$scrobble['artist']] = 0; } $chart[$address][$scrobble['artist']]++; } foreach ($chart as $place => $chart) { arsort($chart); print "<h4>{$place}</h4><ul>"; foreach ($chart as $artist => $plays) { print "<li><b>{$plays}</b>. {$artist}</li>"; } print "</ul><br>"; }
Something failed during the OAuth data fetch from google! Are you sure you have <a href='https://www.google.com/latitude/history'>Google Latitude location history</a> enabled? <?php exit; } $lastTimestamp = $lastLat = $lastLong = null; $json = json_decode($oauth->getLastResponse()); if (!$json->data->items) { print "You don't seem to have a latitude location history yet! Come back when you're older."; exit; } foreach ($json->data->items as $location) { if ($lastTimestamp && $lastLat != $location->latitude && $lastLong != $location->longitude) { $scrobbles = $fetcher->fetchScrobbles($_GET['user'], $location->timestampMs, $lastTimestamp, $location->latitude, $location->longitude); if ($scrobbles) { $address = $fetcher->fetchAddress("{$location->latitude},{$location->longitude}"); print date('r', $location->timestampMs / 1000) . " to " . date('r', $lastTimestamp / 1000) . ": <b>{$address}\n</b><br>"; print "<ul>"; foreach ($scrobbles as $scrobble) { print "<li>{$scrobble['artist']} - {$scrobble['track']}</li>\n"; $foundScrobbles = 1; } print "</ul><br>"; flush(); ob_flush(); } } // Collapse times in the same place if (!$lastTimestamp || $lastLat != $location->latitude && $lastLong != $location->longitude) { $lastLat = $location->latitude; $lastLong = $location->longitude;