WebService::MobileMe - access MobileMe iPhone stuffs from Perl
version 0.002
use WebService::MobileMe; my $mme = WebService::MobileMe->new( username => 'yaakov', password => 'HUGELOVE' ); my $location = $mme->locate; print <<"EOT"; As of $location->{date}, $location->{time}, Yaakov was at $location->{latitude}, $location->{longitude} (plus or minus $location->{accuracy} meters). EOT $mme->sendMessage( message => 'Hi Yaakov!', alarm => 1 );
This module is alpha software released under the release early, release sort of often principle. It works for me but contains no error checking yet, soon to come!
This module supports retrieving a latitude/longitude, and sending a message to an iPhone via the 'Find My iPhone' service from Apple's MobileMe, emulating the AJAX browser client.
new
my $mme = new WebService::MobileMe->new( username => '', password => '');
Returns a new WebService::MobileMe object. Currently the only arguments are username and password, coresponding to your MobileMe login.
WebService::MobileMe
The constructor logs in to Mobile Me and retrieves the first device on the account, storing it for use in the other methods. If something fails, it will return undef.
locate
my $location = $mme->locate();
Takes no arguments, returns a referrence to a hash of the information returned by Apple.
This is currently:
$location = { 'isAccurate' => bless( do{\(my $o = 0)}, 'JSON::PP::Boolean' ), 'longitude' => '-74.51767', 'isRecent' => bless( do{\(my $o = 1)}, 'JSON::PP::Boolean' ), 'date' => 'July 24, 2009', 'status' => 1, 'time' => '10:39 AM', 'isLocationAvailable' => $VAR1->{'isRecent'}, 'statusString' => 'locate status available', 'isLocateFinished' => $VAR1->{'isAccurate'}, 'isOldLocationResult' => $VAR1->{'isRecent'}, 'latitude' => '39.437691', 'accuracy' => '323.239746' };
my $r = $mme->sendMessage( message => 'Hello, World!', alarm => 1);
Takes one required and three optional arguments. Returns a structure containg the parsed JSON returned by apple
message (REQUIRED)
message
The message to display.
alarm
A true value cause the iPhone to make noise when the message is displayed, defaults to false.
device_number
The device number on the account to send the message to. Defaults to 0, the first device. Only the first device is currently captured after logging in.
The returned structure currently looks like:
$r = { 'unacknowledgedMessagePending' => bless( do{\(my $o = 1)}, 'JSON::PP::Boolean' ), 'date' => 'July 24, 2009', 'status' => 1, 'time' => '11:11 AM', 'statusString' => 'message sent' };
To install WebService::MobileMe, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WebService::MobileMe
CPAN shell
perl -MCPAN -e shell install WebService::MobileMe
For more information on module installation, please visit the detailed CPAN module installation guide.