| Geo-Google-Latitude documentation | Contained in the Geo-Google-Latitude distribution. |
Geo::Google::Latitude - Retrieves a Google Latitude Public Location Badge
use Geo::Google::Latitude;
my $gl=Geo::Google::Latitude->new;
my $id="7832225593622256926";
my $badge=$gl->get($id); #isa L<Geo::Google::Latitude::Badge>
printf "Time: %s, Lat: %s, Lon: %s\n", $badge->point->datetime,
$badge->point->latlon;
Perl Object Interface to the Google Latitude Public Location Badge. In order to enable Google Latitude on your mobile device, download Google Maps Mobile and set the permission to share to the public.
use Geo::Google::Latitude;
Returns a Geo::Google::Latitude blessed object. If you need to override the API URL you may do so with the optional url parameter.
my $gl=Geo::Google::Latitude->new; my $gl=Geo::Google::Latitude->new(url=>"http://www.google.com/latitude/apps/badge/api");
Fetches the Google Latitude Public Location Badge from google.com and returns a Geo::Google::Latitude::Badge object initialized with the returned JSON encoded data.
my $badge=$gl->get($id); #isa L<Geo::Google::Latitude::Badge>
Returns a list of Geo::Google::Latitude::Badge objects with just one HTTP request.
my @badge=$gl->getList($id1, $id2, $id3); #() my $badge=$gl->getList($id1, $id2, $id3); #[]
The getList method has a limit as to the number of badges that can be returned. But, I have know idea what that upper limit would be. The length of a URL is typically limited to 2048 bytes and the few IDs that I have seen are 20 characters long. So, we should be able to support more than 90 IDs in one URL accounting for overhead and comma separators.
Log and send to Geo Perl.
Try Geo Perl.
Michael R. Davis
CPAN ID: MRDVT
STOP, LLC
domain=>michaelrdavis,tld=>com,account=>perl
http://www.stopllc.com/
This program is free software licensed under the...
The BSD License
The full text of the license can be found in the LICENSE file included with this module.
| Geo-Google-Latitude documentation | Contained in the Geo-Google-Latitude distribution. |
package Geo::Google::Latitude; use strict; use warnings; use base qw{Geo::Google::Latitude::Base}; use Geo::Google::Latitude::Badge; use URI qw{}; use LWP::UserAgent qw{}; use JSON::XS qw{}; our $VERSION='0.06'; our $PACKAGE=__PACKAGE__;
sub get { my $self=shift; return $self->getList(@_)->[0]; }
sub getList { my $self=shift; my @id=@_; die("Error: Expecting a list of Google Latitude User IDs.") unless @id; my $uri=URI->new($self->url); $uri->query_form(user=>join(",", @id), type=>"json"); my $ua=LWP::UserAgent->new; $ua->agent("$PACKAGE/$VERSION "); $ua->env_proxy; my $response=$ua->get($uri); my @badge=(); if ($response->is_success) { my $content=$response->decoded_content; my $data=JSON::XS->new->pretty->allow_nonref->decode($content); die("Error: Expected JSON to parse as HASH") unless ref($data) eq "HASH"; foreach my $feature (@{$data->{"features"}}) { push @badge, Geo::Google::Latitude::Badge->new( error=>$response->is_error, status=>$response->status_line, %$feature); } } else { foreach my $id (@id) { my $feature={properties=>{id=>$id}}; push @badge, Geo::Google::Latitude::Badge->new( error=>$response->is_error, status=>$response->status_line, %$feature); } } return wantarray ? @badge : \@badge; } sub url { my $self=shift; unless (defined($self->{"url"})) { $self->{"url"}="http://www.google.com/latitude/apps/badge/api"; } return $self->{"url"}; }
1;