Automatically check-in your Google Latitude position in Brightkite
Tired of waiting for Google to release a proper Latitude API, I went ahead and scribbled latitude2brightkite.sh – a script that checks-in your Google Latitude position to Brightkite using the Brightkite REST API and the Google Public Location Badge.
This script is an ugly mongrel hack, but that is what you get when an aged script kiddie writes something in a hurry. The right way to do it would be to parse Latitude’s JSON output cleanly using the Perl library. But that dirty prototype took me all of ten minutes to set up while unwinding between meetings, and it now works fine in my crontab.
Apart from Bash, the requirements to run this script are the Perl JSON library (available in Debian as libjson-perl) and Curl.
The main limitation of this script is that your Google Public Location Badge has to be enabled and it has to show the best available location. This means that for this script to work, your location has to be public. The privacy conscious among my readers will surely love it !
This script proves that automatic Google Latitude position check-in in Brightkite can be done, it works for me, and the official Google Latitude API will hopefully soon make it obsolete !
Meanwhile, grab the code for latitude2brightkite.sh, put it in your crontab and have more fun with Brightkite and Google Latitude… To me, this is what both services were missing to become truly usable.
Of course, doing it with “XEP-0080 – User Location” via publish-subscribe (“XEP-0080 – PubSub” would make much more sense than polling an HTTP server all the time, but we are not there yet. Meanwhile this script could be made more intelligent by only checking in with Brightkite if the Google Latitude position has changed. I’ll think about it for the next version…
16 responses to “Automatically check-in your Google Latitude position in Brightkite”
Leave a Reply
You must be logged in to post a comment.
> Meanwhile this script could be made more
> intelligent by only checking in with
> Brightkite if the Google Latitude position
> has changed.
Done ! I’ll post it tonight, once I’ll have checked that it behaves well for a few hours…
Great. And that’s even better when you find out everything is already installed on your server and you only need to edit your credentials and your crontab :)
Thanks Jim!
[…] Tired of waiting for Google to release a proper Latitude API, I went ahead and scribbled latitude2brightkite.sh – a script that checks-in your Google Latitude position to Brightkite using the Brightkite REST API and the Google Public Location Badge. See my seminal post from yesterday for more information about how I cobbled it together. […]
The updated version of this script that checks-in with Brightkite only if the Google Latitude position has changed, is now online : http://serendipity.ruwenzori.net/index.php/2009/06/05/automatic-check-in-of-google-latitude-position-to-brightkite-now-less-stupid
[…] If this is the Beta, I can’t wait to see what other goodies they’re going to add for us in later releases. After all, there already is a project that lets you auto check-in via Google Latitude. […]
[…] If this is the Beta, I can’t wait to see what other goodies they’re going to add for us in later releases. After all, there already is a project that lets you auto check-in via Google Latitude. […]
I dont understand will you still need to edit your crontab
On invocation, the script runs only once. So if you want your position to be updated automatically, you need to run the script periodically. The traditional Unix way is to do it with Crontab – but use whatever you want to launch the script !
I could have written it as a daemon with an infinite loop, but because of the short execution time and the long time between updates (unless you wan to hammer Google’s servers) a single update script made more sense to me.
I just tried to set up the script and I’m getting an error “unrecognized switch: -Esay to_json(from_json($_, {allow_nonref=>1}, {pretty=>1}) (-h will show valid options”
this is on a box with perl 5.8.8, with JSON installed from cpan.
I’ve tried changing -nE to -ne or -n -e or just -n but they’re all giving errors… any suggestions?
doing a little more research, the -E option is only in perl 5.10, so perl 5.8.8 won’t work. To get it to work in perl 5.8.8 (and probably lower I made the following change:
coordinates=`wget -qO- “$badge” | perl -0007 -MJSON -ne ‘print to_json(from_json($_, {allow_nonref=>1}), {pretty=>1})’ | grep -A 2 coordinates | grep -v coordinates | sed s/,//`
Google Latitude Brightkite check-in script updated to version 0.5 including Jay’s contribution.
Google Latitude Brightkite check-in script updated to version 0.5…
I just released a new update of latitude2brightkite.sh – a script that checks-in your Google Latitude position to Brightkite using the Brightkite REST API and the Google Public Location Badge.
The changes are :
20090607 – 0.3 – The working directory i…
just tried to set up the script and I’m getting an error “unrecognized switch: -Esay to_json(from_json($_, {allow_nonref=>1}, {pretty=>1}) (-h will show valid options”
Hey, thanks for the script -I am learning to program, and learning by example – this little script is great for learning a little more about json – I hope you don’t mind – but I modified the script to send my Google Latitude to twitter – and would like to modify it to inject latitude in the Amateur APRS network – But anyways – Great learning tool, and more! Thanks
@LeRoy Of course you are welcome to take the script and roll with it – that is how I started with other people’s code too. Just make sure you release your modified version somewhere so that other can continue this improvement and modification process !
[…] So here is a new update of latitude2brightkite.sh – a script that checks-in your Google Latitude position to Brightkite using the Brightkite API and the Google Public Location Badge. Description of the whole contraption may be found in the initial announcement. […]