Net::Douban::User - Net::Douban::User documentation


Net-Douban documentation Contained in the Net-Douban distribution.

Index


Code Index:

NAME

Top

Net::Douban::User

VERSION

Top

version 1.07

SYNOPSIS

Top

	use Net::Douban::User;
	my $user = Net::Douban::User->new(
		userID => 'Net-Douban',
		apikey => '....',
        # or
        oauth => $consumer,
	);
	$user->userID('abei');

	$atom = $user->get_user;
	$atom = $user->get_friends;
	$atom = $user->get_contacts;
    $atom = $user->search(q => 'douban', start_index => 5, max_results => 10);

DESCRIPTION

Top

Interface to douban.com API User section

METHODS

Top

Those methods return a Net::Douban::Atom object which can be use to get data conveniently

get_user
get_contacts
get_friends
get_auth_user
search

SEE ALSO

Top

Net::Douban Net::Douban::Atom Moose XML::Atom http://www.douban.com/service/apidoc/reference/user

AUTHOR

Top

woosley.xu<redicaps@gmail.com>

COPYRIGHT

Top


Net-Douban documentation Contained in the Net-Douban distribution.

package Net::Douban::User;

BEGIN {
    $Net::Douban::User::VERSION = '1.07';
}

use Moose;
with 'Net::Douban::Roles::More';
use Net::Douban::Atom;
use Carp qw/carp croak/;
use MooseX::StrictConstructor;

has 'userID' => (is => 'rw', isa => 'Str',);

sub get_user {
    my ($self, %args) = @_;
    my $userID = $args{userID} || $self->userID;
    croak "no userId found!" unless $userID;
    return Net::Douban::Atom->new($self->get($self->user_url . "/$userID"));
}

sub search {
    my ($self, %args) = @_;
    croak "no query found in the parameters" unless exists $args{q};
    return Net::Douban::Atom->new($self->get($self->user_url, %args));
}

sub get_auth_user {
    my ($self, %args) = @_;
    return Net::Douban::Atom->new($self->get($self->user_url . '/%40me'));
}

sub get_contacts {
    my ($self, %args) = @_;
    my $userID = delete $args{userID} || $self->userID;
    croak "no userId found!" unless $userID;
    return Net::Douban::Atom->new(
        $self->get($self->user_url . "/$userID/contacts", %args));
}

sub get_friends {
    my ($self, %args) = @_;
    my $userID = delete $args{userID} || $self->userID;
    croak "no userId found!" unless $userID;
    return Net::Douban::Atom->new(
        $self->get($self->user_url . "/$userID/friends", %args));
}

no Moose;
__PACKAGE__->meta->make_immutable;
1;

__END__