woosley > Net-Douban > Net::Douban

Download:
Net-Douban-1.14.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.14   Source  

NAME ^

Net::Douban - Perl client for douban.com

VERSION ^

version 1.14

SYNOPSIS ^

    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;

DESCRIPTION ^

Net::Douban is a perl client wrapper on the Chinese website 'douban.com' API.

METHODS ^

init

init is the new for Net::Douban. it is here because of MooseX::Traits limits

    $client = Net::Douban->init(Traits => 'Gift');
    $client = Net::Douban->init(Roles  => 'User');

OAuth ^

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);

API ^

Roles

    $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

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');

res_callback

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

Paging is support by passing argments 'start-index' and 'max-results' to search and get functions.

SEE ALSO ^

Net::Douban::OAuth Net::Douban::Traits::Gift Net::Douban::User Net::Douban::Utils

AUTHOR ^

woosley.xu <woosley.xu@gmail.com>

COPYRIGHT & LICENSE ^

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.

syntax highlighting: