Magnus Erixzon > WWW-Google-Contacts-0.38 > WWW::Google::Contacts

Download:
WWW-Google-Contacts-0.38.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  2
View/Report Bugs
Module Version: 0.38   Source  

SYNOPSIS ^

    use WWW::Google::Contacts;

    my $google = WWW::Google::Contacts->new(
        username => "your.username",
        password => "your.password",
        protocol => "https",
    );

    # Create a new contact
    my $contact = $google->new_contact;
    $contact->full_name("Emmett Brown");
    $contact->name_prefix("Dr");
    $contact->email('doctor@timetravel.org');
    $contact->hobby("Time travel");
    $contact->jot([ "Went back in time", "Went forward in time", "Became blacksmith" ]),
    $contact->create;  # save it to the server

    # Now search for the given name, and read the jots
    my @contacts = $google->contacts->search({ given_name => "Emmett" });
    foreach my $c ( @contacts ) {
        print "Got the following jots about the good doctor\n";
        foreach my $jot ( @{ $c->jot } ) {
            print "Jot: " . $jot->value . "\n";
        }
        print "And now he goes back to the future\n";
        $c->delete;
    }

    # Print the names of all groups
    my $groups = $google->groups;
    while ( my $group = $groups->next ) {
        print "Title = " . $group->title . "\n";
    }

    # Add the contact to existing group 'Movie stars' and to a new group 'Back to the future'
    my $new_group = $google->new_group({ title => "Back to the future" });
    $new_group->create;  # create on server

    my @groups = $google->groups->search({ title => "Movie stars" });
    my $movie_stars_group = shift @groups;

    $contact->add_group_membership( $new_group );
    $contact->add_group_membership( $movie_stars_group );
    $contact->update;

DESCRIPTION ^

This module implements 'Google Contacts Data API' according http://code.google.com/apis/contacts/docs/3.0/developers_guide_protocol.html

NOTE This new interface is still quite untested. Please report any bugs.

CONSTRUCTOR ^

new( username => .., password => .. , protocol => ..)

username and password are required arguments and must be valid Google credentials. If you do not have a Google account you can create one at https://www.google.com/accounts/NewAccount.

protocol defaults to http, but can optionally be set to https.

METHODS ^

$google->new_contact

Returns a new empty WWW::Google::Contacts::Contact object.

$google->contact( $id )

Given a valid contact ID, returns a WWW::Google::Contacts::Contact object populated with contact data from Google.

$google->contacts

Returns a WWW::Google::Contacts::ContactList object which can be used to iterate over all your contacts.

$google->new_group

Returns a new WWW::Google::Contacts::Group object.

$google->group( $id )

Given a valid group ID, returns a WWW::Google::Contacts::Group object populated with group data from Google.

$google->groups

Returns a WWW::Google::Contacts::GroupList object which can be used to iterate over all your groups.

DEPRECATED METHODS ^

The old module interface is still available, but its use is discouraged. It will eventually be removed from the module.

SEE ALSO ^

WWW::Google::Contacts::Contact

WWW::Google::Contacts::ContactList

WWW::Google::Contacts::Group

WWW::Google::Contacts::GroupList

http://code.google.com/apis/contacts/docs/3.0/developers_guide_protocol.html

ACKNOWLEDGEMENTS ^

Fayland Lam - who wrote the first version of this module

John Clyde - who shared his code about Contacts API with Fayland

TODO ^

More POD
Unit tests. Very lame right now
Images
Fix bugs :)

AUTHOR ^

  Magnus Erixzon <magnus@erixzon.com>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2010 by Magnus Erixzon.

This is free software; you can redistribute it and/or modify it under the same terms as perl itself.

syntax highlighting: