-
Notifications
You must be signed in to change notification settings - Fork 2
/
README
88 lines (65 loc) · 2.81 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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 <[email protected]>
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.