| Net-Douban documentation | Contained in the Net-Douban distribution. |
Net::Douban::Miniblog;
version 1.07
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');
Interface to douban.com API Miniblog section
Those methods return a Net::Douban::Atom object which can be use to get data conveniently
Net::Douban Net::Douban::Atom Moose XML::Atom http://www.douban.com/service/apidoc/reference/miniblog
woosley.xu<redicaps@gmail.com>
Copyright (C) 2010 by Woosley.Xu
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.
| 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__