The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

WebService::MobileMe - access MobileMe iPhone stuffs from Perl

VERSION

version 0.002

SYNOPSIS

    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 );

DESCRIPTION

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.

METHODS

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.

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'
    };

sendMessage

    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)

    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'
    };