Last year, I wrote about how to extract Location History from Google. Once again, Google have changed their URLs to make it even harder to get one’s current location out of their data-greedy hands.
It used to be the case that Latitude gave that information – but they killed it. Then they promised it in Google+ – but never delivered. Now they offer you a data-dump which they will email to you. Hardly convenient if you want a single day!
Recently Google released Timeline – an interactive way to view where you’ve been. It also offers the ability to download a single day’s worth of location tracks as KML.
With a little bit of fiddling, we can get the direct URL. Strap in, it’s going to get rough!
In order to get today’s date (2015-09-02) the URL needs to be:
That URL format is… unique…
Here’s how it breaks down:
One thing to note, when you get the KML file, the timestamps are in ISO 8601 format (Yay!) but are set to West Coast USA time (Boo!)
Annoying, but not the end of the world. How do you get the data into your app?
There’s no authorised API access for this. You can’t do the OAuth dance. The only way is via cookie-jacking.
Sign in to Google via your web browser. Open up your web inspector in Chrome or Firefox. Load the KML URL and choose “Copy as cURL”
You’ll end up with a command like:
curl 'https://www.google.com/maps/timeline/kml?authuser=0&pb=!1m8!1m3!1i2015!2i8!3i2!2m3!1i2015!2i8!3i2' -H 'Host: www.google.com' -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:40.0) Gecko/20100101 Firefox/40.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' -H 'Accept-Language: en-GB,en;q=0.5' --compressed -H 'DNT: 1' -H 'Cookie: --------------' -H 'Connection: keep-alive'
You can use that command – or steal your own cookie – for use in your app. Your cookie will likely expire after a set time – whereupon you’ll have to reauthenticate.
What a faff! Come on, Google. Rather than pissing about with your logo, why not build something that works properly? I dare ya!