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

NAME

WWW::Contact - Get contacts/addressbook from Web

SYNOPSIS

    use WWW::Contact;
    
    # Get contacts from email providers.
    my $wc       = WWW::Contact->new();
    my @contacts = $wc->get_contacts('fayland@gmail.com', 'password');
    my $errstr   = $wc->errstr;
    if ($errstr) {
        die $errstr; # like 'Wrong Password'
    } else {
        print Dumper(\@contacts);
    }
    
    # Get contacts from social networks.(eg: Plaxo)
    my $ws       = WWW::Contact->new();
    # Note that the last argument for get_contacts() is mandatory,
    # or else it will try to fetch contacts from gmail.com
    my @contacts = $ws->get_contacts('itsa@gmail.com', 'password', 'plaxo');
    my $errstr   = $ws->errstr;
    if ($errstr) {
        die $errstr; # like 'Wrong Username or Password'
    } else {
        print Dumper(\@contacts);
    }
    

DESCRIPTION

Get Contacts/AddressBook from public websites.

SUPPORTED EMAIL SUPPLIER

Gmail

WWW::Contact::Gmail By Fayland Lam

Yahoo! Mail

WWW::Contact::Yahoo By Fayland Lam

Rediffmail

WWW::Contact::Rediffmail By Sachin Sebastian

mail.163.com

WWW::Contact::CN::163 By Fayland Lam

AOL

WWW::Contact::AOL By Fayland Lam

Mail

WWW::Contact::Mail By Sachin Sebastian

Hotmail/Live Mail

WWW::Contact::Hotmail By Fayland Lam

Indiatimes

WWW::Contact::Indiatimes By Sachin Sebastian

Lycos

WWW::Contact::Lycos By Sachin Sebastian

Plaxo

WWW::Contact::Plaxo By Sachin Sebastian

METHODS

register_supplier

To use custom supplier, we must register within WWW::Contact

    $wc->register_supplier( qr/\@a\.com$/, 'Unknown' );
    $wc->register_supplier( 'a.com', 'Unknown' );

The first arg is a Regexp or domain from email postfix. The second arg is the according module postfix like 'Unknown' form WWW::Contact::Unknown

get_supplier_by_email

get supplier by email.

    my $supplier = $wc->get_supplier_by_email('a@gmail.com'); # 'Gmail'
    my $supplier = $wc->get_supplier_by_email('a@a.com');     # 'Unknown'

get_supplier_by_socialnetwork

get supplier by social network name.

    my $supplier = $wc->get_supplier_by_socialnetwork('plaxo'); # 'Plaxo'

HOW TO WRITE YOUR OWN MODULE

please read WWW::Contact::Base and examples: WWW::Contact::Yahoo and WWW::Contact::Plaxo

Assuming we write a custom module as WWW::Contact::Unknown

    package WWW::Contact::Unknown;
    
    use Moose;
    extends 'WWW::Contact::Base';
    
    sub get_contacts {
        my ($self, $email, $password) = @_;
        
        # reset
        $self->errstr(undef);
        
        if ($email eq 'a@a.com' and $password ne 'a') {
            $self->errstr('Wrong Username or Password');
            return;
        }
        
        my @contacts = ( {
            email => 'b@b.com',
            name => 'b',
        }, {
            email => 'c@c.com',
            name => 'c'
        } );
        return wantarray ? @contacts : \@contacts;
    }
    
    1;

We can use it within WWW::Contact

    my $wc = new WWW::Contact;
    $wc->register_supplier( qr/\@a\.com$/, 'Unknown' );
    # or
    # $wc->register_supplier( 'a.com', 'Unknown' );
    
    my @contacts = $wc->get_contacts('a@a.com', 'b');
    my $errstr = $wc->errstr;

SEE ALSO

WWW::Mechanize, Moose

SUPPORTS

Code trunk

http://code.google.com/p/perl-www-contact/

Group

http://groups.google.com/group/perl-www-contact

AUTHOR

Fayland Lam, <fayland at gmail.com>

Sachin Sebastian, <sachinjsk at cpan.org>

COPYRIGHT & LICENSE

Copyright 2008 *AUTHOR* all rights reserved.

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