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

NAME

WWW::Google::Contacts - Google Contacts Data API

VERSION

version 0.07

SYNOPSIS

    use WWW::Google::Contacts;

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

    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;

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


    my $groups = $google->groups;
    while ( my $group = $groups->next ) {
        print "Title = " . $group->title . "\n";
    }

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 => .. )

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.

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.

  • new/login

        my $gcontacts = WWW::Google::Contacts->new();
        $gcontacts->login('fayland@gmail.com', 'pass') or die 'login failed';
  • create_contact

        $gcontacts->create_contact( {
            givenName => 'FayTestG',
            familyName => 'FayTestF',
            fullName   => 'Fayland Lam',
            Notes     => 'just a note',
            primaryMail => 'primary@example.com',
            displayName => 'FayTest Dis',
            secondaryMail => 'secndary@test.com', # optional
        } );

    return 1 if created

  • get_contacts

        my @contacts = $gcontacts->get_contacts;
        my @contacts = $gcontacts->get_contacts( {
            group => 'thin', # default to 'full'
        } )
        my @contacts = $gcontacts->get_contacts( {
            updated-min => '2007-03-16T00:00:00',
            start-index => 10,
            max-results => 99, # default as 9999
        } );

    get contacts from this account.

    group refers http://code.google.com/apis/contacts/docs/2.0/reference.html#Projections

    start-index, max_results etc refer http://code.google.com/apis/contacts/docs/2.0/reference.html#Parameters

  • get_contact($id)

        my $contact = $gcontacts->get_contact('http://www.google.com/m8/feeds/contacts/account%40gmail.com/base/1');

    get a contact by id

  • update_contact

        my $status = $gcontacts->update_contact('http://www.google.com/m8/feeds/contacts/account%40gmail.com/base/123623e48cb4e70a', {
            givenName => 'FayTestG2',
            familyName => 'FayTestF2',
            fullName   => 'Fayland Lam2',
            Notes     => 'just a note2',
            primaryMail => 'primary@example2.com',
            displayName => 'FayTest2 Dis',
            secondaryMail => 'secndary@test62.com', # optional
        } );

    update a contact

  • delete_contact($id)

        my $status = $gcontacts->delete_contact('http://www.google.com/m8/feeds/contacts/account%40gmail.com/base/1');

    The id is from get_contacts.

  • create_group

        my $status = $gcontacts->create_group( { title => 'Test Group' } );

    Create a new group

  • get_groups

        my @groups = $gcontacts->get_groups;
        my @groups = $gcontacts->get_groups( {
            updated-min => '2007-03-16T00:00:00',
            start-index => 10,
            max-results => 99, # default as 9999
        } );

    Get all groups.

  • get_group($id)

        my $group = $gcontacts->get_group('http://www.google.com/m8/feeds/groups/account%40gmail.com/base/6e744e7d0a4b398c');

    get a group by id

  • update_group($id, { title => $title })

        my $status = $gcontacts->update_group( 'http://www.google.com/m8/feeds/groups/account%40gmail.com/base/6e744e7d0a4b398c', { title => 'New Test Group 66' } );

    Update a group

  • delete_group

        my $status = $gcontacts->delete_contact('http://www.google.com/m8/feeds/groups/account%40gmail.com/base/6e744e7d0a4b398c');

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

John Clyde - who share me with his code about Contacts API

TODO

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

AUTHOR

  Fayland Lam <fayland@gmail.com>
  Magnus Erixzon <magnus@erixzon.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2010 by Fayland Lam.

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

AUTHORS

  • Fayland Lam <fayland@gmail.com>

  • Magnus Erixzon <magnus@erixzon.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2010 by Fayland Lam.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.