Net::Douban - Perl client for douban.com
version 1.14
use Net::Douban; my $client = Net::Douban->init(Traits => 'Gift'); my $client = Net::Douban->init(Roles => [qw/User Review .../]); $client->res_callback(sub{shift}); print $client->get_user_contact(userID => 'Net-Douban')->decoded_content;
Net::Douban is a perl client wrapper on the Chinese website 'douban.com' API.
init is the new for Net::Douban. it is here because of MooseX::Traits limits
Net::Douban
MooseX::Traits
$client = Net::Douban->init(Traits => 'Gift'); $client = Net::Douban->init(Roles => 'User');
Here is how to get the tokens before you can access the website
my $c = Net::Douban->init(consumer_key =>'...', consumer_secret =>'...'); $c->get_request_token; ## ask your customer go to this url to allow the access to his account print $c->paste_url(); <>; $c->get_access_token; ## now you can save those tokens say $c->request_token, $c->request_token_secret, $c->access_token, $c->access_token_secret; ## next time you can load tokens,all tokens are needed, the key for the hash is the name of the method. $c->load_token(%token_hash);
$client = Net::Douban->init(Roles => [qw/User Review/]);
Roles are just individual douban API sections. You can pass Roles to the constructure, then those sections are loaded to the object. Avalable roles are qw/User Subject Review Collection Miniblog Note Event Recommendation Review Doumail Tag/
Traits are special Roles, Right now just there is just a Net::Douban::Traits::Gift, you can write your own trait, refer to Net::Douban::Traits::Gift to see how to do it.
When you want to use Traits under your own namespace(that is not under Net::Douban), you should pass it with a '+' in front of the name;
$c = Net::Douban->init("Traits" => '+My::Trait');
You can use your own res_callback to handle the returned HTTP::Response object by:
$client->res_callback(sub{....});
The only argument for this callback is $res return from LWP::UserAgent. By default, res_callback will return the decoded JSON hash.
Paging is support by passing argments 'start-index' and 'max-results' to search and get functions.
Net::Douban::OAuth Net::Douban::Traits::Gift Net::Douban::User Net::Douban::Utils
woosley.xu <woosley.xu@gmail.com>
This software is copyright (c) 2010 - 2011 by woosley.xu.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Net::Douban, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Douban
CPAN shell
perl -MCPAN -e shell install Net::Douban
For more information on module installation, please visit the detailed CPAN module installation guide.