Net::Douban::Miniblog - Net::Douban::Miniblog documentation


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

Index


Code Index:

NAME

Top

Net::Douban::Miniblog;

VERSION

Top

version 1.07

SYNOPSIS

Top

	use Net::Douban::Miniblog;
	$miniblog = Net::Douban::Miniblog->new(
		apikey => '....',
        # or
        oauth => $consumer,
	);

	$atom = $miniblog->get_user_miniblog(userID => 'Net-Douban');
	$atom = $miniblog->get_contact_miniblog(userID => 'Net-Douban');

DESCRIPTION

Top

Interface to douban.com API Miniblog section

METHODS

Top

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

get_user_miniblog
get_contact_miniblog
post_saying
delete_miniblog
get_reply
post_reply

SEE ALSO

Top

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

AUTHOR

Top

woosley.xu<redicaps@gmail.com>

COPYRIGHT

Top


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

package Net::Douban::Miniblog;

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

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

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

has 'miniblog_url' => (
    is      => 'rw',
    isa     => 'Url',
    lazy    => 1,
    default => sub { shift->base_url . '/miniblog' }
);

sub get_user_miniblog {
    my ($self, %args) = @_;
    my $uid = delete $args{userID} or croak "userID needed";
    return Net::Douban::Atom->new(
        $self->get($self->user_url . "/$uid/miniblog", %args));
}

sub get_contact_miniblog {
    my ($self, %args) = @_;
    my $uid = delete $args{userID} or croak "userID needed";
    return Net::Douban::Atom->new(
        $self->get($self->user_url . "/$uid/miniblog/contacts", %args));
}

sub post_saying {
    my ($self, %args) = @_;
    croak "post xml needed!" unless exists $args{xml};
    return $self->post($self->miniblog_url . "/saying", %args);
}

sub delete_miniblog {
    my ($self, %args) = @_;
    $args{miniblogID} ||= $self->miniblogID;
    croak "miniblogID needed!" unless exists $args{miniblogID};
    return $self->delete($self->miniblog_url . "/$args{miniblogID}");
}

sub get_reply {
    my ($self, %args) = @_;
    $args{miniblogID} ||= $self->miniblogID;
    croak "miniblogID needed!" unless exists $args{miniblogID};
    return Net::Douban::Atom->new(
        $self->get($self->miniblog_url . "/$args{miniblogID}/" . "comments"));
}

sub post_reply {
    my ($self, %args) = @_;
    $args{miniblogID} ||= $self->miniblogID;
    my $mid = delete $args{miniblogID} or croak "miniblogID needed!";
    croak "post xml needed!" unless exists $args{xml};
    return $self->post($self->miniblog_url . "/$mid/comments", %args);
}

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

__END__