| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WebService::BuzzurlAPI; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=pod |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
WebService::BuzzurlAPI - Buzzurl WebService API |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 VERSION |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
0.02 |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use WebService::BuzzurlAPI; |
|
16
|
|
|
|
|
|
|
use strict; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $buzz = WebService::BuzzurlAPI->new(email => "your email", password => "your password"); |
|
19
|
|
|
|
|
|
|
# readers api |
|
20
|
|
|
|
|
|
|
my $res = $buzz->readers( userid => "your userid" ); |
|
21
|
|
|
|
|
|
|
if($res->is_success){ |
|
22
|
|
|
|
|
|
|
my $json = $res->json; |
|
23
|
|
|
|
|
|
|
# do something |
|
24
|
|
|
|
|
|
|
}else{ |
|
25
|
|
|
|
|
|
|
die $res->errstr; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Buzzurl is social bookmark service. |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
For more information on Buzzurl, visit the Buzzurl website. http://buzzurl.jp/. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
API Reference. http://labs.ecnavi.jp/developer/buzzurl/api/ |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
|
37
|
|
|
|
|
|
|
|
|
38
|
9
|
|
|
9
|
|
312651
|
use strict; |
|
|
9
|
|
|
|
|
23
|
|
|
|
9
|
|
|
|
|
287
|
|
|
39
|
9
|
|
|
9
|
|
46
|
use warnings; |
|
|
9
|
|
|
|
|
18
|
|
|
|
9
|
|
|
|
|
286
|
|
|
40
|
9
|
|
|
9
|
|
48
|
use base qw(Class::Accessor); |
|
|
9
|
|
|
|
|
19
|
|
|
|
9
|
|
|
|
|
16207
|
|
|
41
|
9
|
|
|
9
|
|
30165
|
use Carp; |
|
|
9
|
|
|
|
|
24
|
|
|
|
9
|
|
|
|
|
970
|
|
|
42
|
9
|
|
|
9
|
|
14775
|
use LWP::UserAgent; |
|
|
9
|
|
|
|
|
657382
|
|
|
|
9
|
|
|
|
|
394
|
|
|
43
|
9
|
|
|
9
|
|
11605
|
use Readonly; |
|
|
9
|
|
|
|
|
33549
|
|
|
|
9
|
|
|
|
|
511
|
|
|
44
|
9
|
|
|
9
|
|
14113
|
use UNIVERSAL::require; |
|
|
9
|
|
|
|
|
16954
|
|
|
|
9
|
|
|
|
|
97
|
|
|
45
|
9
|
|
|
9
|
|
261
|
use URI; |
|
|
9
|
|
|
|
|
20
|
|
|
|
9
|
|
|
|
|
151
|
|
|
46
|
9
|
|
|
9
|
|
5951
|
use WebService::BuzzurlAPI::Response; |
|
|
9
|
|
|
|
|
34
|
|
|
|
9
|
|
|
|
|
90
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw(email password)); |
|
50
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors(qw(ua)); |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
our $VERSION = 0.02; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Readonly my $API_URL_FORMAT => "http://api.buzzurl.jp/api/%s/v1/json"; |
|
55
|
|
|
|
|
|
|
Readonly my %ALIAS_PACKAGE => ( |
|
56
|
|
|
|
|
|
|
readers => "Readers", |
|
57
|
|
|
|
|
|
|
favorites => "Favorites", |
|
58
|
|
|
|
|
|
|
url_info => "UrlInfo", |
|
59
|
|
|
|
|
|
|
# counter redirect image api not supported |
|
60
|
|
|
|
|
|
|
# counter => "Counter", |
|
61
|
|
|
|
|
|
|
bookmark_count => "BookmarkCount", |
|
62
|
|
|
|
|
|
|
user_articles => "UserArticles", |
|
63
|
|
|
|
|
|
|
recent_articles => "RecentArticles", |
|
64
|
|
|
|
|
|
|
keyword_articles => "KeywordArticles", |
|
65
|
|
|
|
|
|
|
add => "Add" |
|
66
|
|
|
|
|
|
|
); |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub import { |
|
69
|
|
|
|
|
|
|
|
|
70
|
9
|
|
|
9
|
|
1243
|
no strict "refs"; |
|
|
9
|
|
|
|
|
17
|
|
|
|
9
|
|
|
|
|
3229
|
|
|
71
|
9
|
|
|
9
|
|
103
|
foreach my $method(keys %ALIAS_PACKAGE){ |
|
72
|
|
|
|
|
|
|
|
|
73
|
72
|
|
|
|
|
15587
|
*{$method} = sub { |
|
74
|
|
|
|
|
|
|
|
|
75
|
3
|
|
|
3
|
|
28
|
my($self, %args) = @_; |
|
76
|
3
|
|
|
|
|
39
|
my $pkg = sprintf "%s::Request::%s", __PACKAGE__, $ALIAS_PACKAGE{$method}; |
|
77
|
3
|
50
|
|
|
|
118
|
$pkg->require or croak($UNIVERSAL::require::ERROR); |
|
78
|
3
|
|
|
|
|
76
|
my $req = $pkg->new( buzz => $self, uri => URI->new($API_URL_FORMAT) ); |
|
79
|
3
|
|
|
|
|
75
|
my $res = WebService::BuzzurlAPI::Response->new($req->request(%args)); |
|
80
|
3
|
|
|
|
|
33
|
$res->analysis_response; |
|
81
|
3
|
|
|
|
|
83
|
return $res; |
|
82
|
72
|
|
|
|
|
583
|
}; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=pod |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 METHOD |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 new |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Create instance |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Option: |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
email : your login email(require when add api) |
|
97
|
|
|
|
|
|
|
password : your login password(require when add api) |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Example: |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
my $buzz = WebService::BuzzurlAPI->new(email => "your email", password => "your password"); |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub new { |
|
106
|
|
|
|
|
|
|
|
|
107
|
4
|
|
|
4
|
1
|
56
|
my($class, %args) = @_; |
|
108
|
4
|
|
|
|
|
52
|
my $ua = LWP::UserAgent->new; |
|
109
|
4
|
|
|
|
|
34537
|
$ua->agent(sprintf "%s/%f", __PACKAGE__, $VERSION); |
|
110
|
4
|
|
33
|
|
|
402
|
return bless { |
|
111
|
|
|
|
|
|
|
email => $args{email}, |
|
112
|
|
|
|
|
|
|
password => $args{password}, |
|
113
|
|
|
|
|
|
|
ua => $ua, |
|
114
|
|
|
|
|
|
|
}, $class || ref($class); |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=pod |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 readers |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Get readers userid |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Options: |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
userid : userid(require) |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Example: |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
my $res = $buzz->readers( userid => "userid" ); |
|
130
|
|
|
|
|
|
|
if($res->is_success){ |
|
131
|
|
|
|
|
|
|
foreach my $userid(@{$res->json}){ |
|
132
|
|
|
|
|
|
|
# do something... |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head2 favorites |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Get favorites userid |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Options: |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
userid : userid(require) |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Example: |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
my $res = $buzz->favorites( userid => "userid" ); |
|
147
|
|
|
|
|
|
|
if($res->is_success){ |
|
148
|
|
|
|
|
|
|
foreach my $userid(@{$res->json}){ |
|
149
|
|
|
|
|
|
|
# do something... |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 url_info |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Get url info |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Options: |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
url : url(require) |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Example: |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
my $res = $buzz->url_info( url => "http://your.wanted.domain/" ); |
|
164
|
|
|
|
|
|
|
if($res->is_success){ |
|
165
|
|
|
|
|
|
|
my $urlinfo = shift @{$res->json}; |
|
166
|
|
|
|
|
|
|
my $url = $urlinfo->{url}; |
|
167
|
|
|
|
|
|
|
my $title = $urlinfo->{title}; |
|
168
|
|
|
|
|
|
|
my $user_num = $urlinfo->{user_num}; |
|
169
|
|
|
|
|
|
|
foreach my $ref(@{$userinfo->{posts}}){ |
|
170
|
|
|
|
|
|
|
my $keywords = $ref->{keywords}; |
|
171
|
|
|
|
|
|
|
my $comment = $ref->{comment}; |
|
172
|
|
|
|
|
|
|
my $date = $ref->{date}; |
|
173
|
|
|
|
|
|
|
my $user_name = $ref->{user_name}; |
|
174
|
|
|
|
|
|
|
} |
|
175
|
|
|
|
|
|
|
# do something... |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head2 bookmark_count |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Get bookmark count |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
Options: |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
url : url(require max:30) |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Example: |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
my $res = $buzz->bookmark_count( url => "http://your.wanted.domain" ); |
|
189
|
|
|
|
|
|
|
# multiple |
|
190
|
|
|
|
|
|
|
# my $res = $buzz->bookmark_count( url => [ "http://your.wanted.domain", "http://your.wanted.domain2" ] ); |
|
191
|
|
|
|
|
|
|
if($res->is_success){ |
|
192
|
|
|
|
|
|
|
foreach my $ref(@{$res->json}){ |
|
193
|
|
|
|
|
|
|
my $url = $ref->{url}; |
|
194
|
|
|
|
|
|
|
my $title = $ref->{title}; |
|
195
|
|
|
|
|
|
|
my $users = $ref->{users}; |
|
196
|
|
|
|
|
|
|
# do something... |
|
197
|
|
|
|
|
|
|
} |
|
198
|
|
|
|
|
|
|
} |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head2 user_articles |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Get user articles |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Options: |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
userid : userid(require) |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Example: |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
my $res = $buzz->user_articles( userid => "userid" ); |
|
211
|
|
|
|
|
|
|
if($res->is_success){ |
|
212
|
|
|
|
|
|
|
foreach my $ref(@{$res->json}){ |
|
213
|
|
|
|
|
|
|
my $url = $ref->{url}; |
|
214
|
|
|
|
|
|
|
my $title = $ref->{title}; |
|
215
|
|
|
|
|
|
|
my $comment = $ref->{comment}; |
|
216
|
|
|
|
|
|
|
my $keywords = $ref->{keywords}; |
|
217
|
|
|
|
|
|
|
# do something... |
|
218
|
|
|
|
|
|
|
} |
|
219
|
|
|
|
|
|
|
} |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=head2 recent_articles |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
Get recent articles |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
Options: |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
num : get number(default:5) |
|
228
|
|
|
|
|
|
|
of : page number(default:0) |
|
229
|
|
|
|
|
|
|
threshold : bookmark count threshold(default:0) |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
Example: |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
my $res = $buzz->recent_articles( num => 0, of => 1, threshold => 3 ); |
|
234
|
|
|
|
|
|
|
if($res->is_success){ |
|
235
|
|
|
|
|
|
|
foreach my $ref(@{$res->json}){ |
|
236
|
|
|
|
|
|
|
my $url = $ref->{url}; |
|
237
|
|
|
|
|
|
|
my $title = $ref->{title}; |
|
238
|
|
|
|
|
|
|
my $user_num = $ref->{user_num}; |
|
239
|
|
|
|
|
|
|
my $user_id = $ref->{user_id}; |
|
240
|
|
|
|
|
|
|
my $register_date = $ref->{register_date}; |
|
241
|
|
|
|
|
|
|
# do something... |
|
242
|
|
|
|
|
|
|
} |
|
243
|
|
|
|
|
|
|
} |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=head2 keyword_articles |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
Get keyword articles |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
Options: |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
userid : userid(require) |
|
252
|
|
|
|
|
|
|
keyword : keyword string(require) |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
Example: |
|
255
|
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
my $res = $buzz->keyword_articles( userid => "userid", keyword => "keyword string" ); |
|
257
|
|
|
|
|
|
|
if($res->is_success){ |
|
258
|
|
|
|
|
|
|
foreach my $ref(@{$res->json}){ |
|
259
|
|
|
|
|
|
|
my $url = $ref->{url}; |
|
260
|
|
|
|
|
|
|
my $title = $ref->{title}; |
|
261
|
|
|
|
|
|
|
my $user_num = $ref->{user_num}; |
|
262
|
|
|
|
|
|
|
my $user_id = $ref->{user_id}; |
|
263
|
|
|
|
|
|
|
my $register_date = $ref->{register_date}; |
|
264
|
|
|
|
|
|
|
# do something... |
|
265
|
|
|
|
|
|
|
} |
|
266
|
|
|
|
|
|
|
} |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=head2 add |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
Add my bookmark(https + basic auth access) |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
Options: |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
url : bookmark url(require) |
|
275
|
|
|
|
|
|
|
title : bookmark title |
|
276
|
|
|
|
|
|
|
comment : bookmark comment |
|
277
|
|
|
|
|
|
|
keyword : bookmark keyword(max:8) |
|
278
|
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
Example: |
|
280
|
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
my $res = $buzz->add( |
|
282
|
|
|
|
|
|
|
url => "http://your.register.domain/", |
|
283
|
|
|
|
|
|
|
title => "my bookmark title", |
|
284
|
|
|
|
|
|
|
comment => "my bookmark comment", |
|
285
|
|
|
|
|
|
|
keyword => "my keyword", |
|
286
|
|
|
|
|
|
|
# multiple keyword |
|
287
|
|
|
|
|
|
|
keyword => [ "my keyword", "my keyword2" ], |
|
288
|
|
|
|
|
|
|
); |
|
289
|
|
|
|
|
|
|
if($res->is_success){ |
|
290
|
|
|
|
|
|
|
print $res->json->{status} . "\n"; |
|
291
|
|
|
|
|
|
|
}else{ |
|
292
|
|
|
|
|
|
|
die $res->errstr; |
|
293
|
|
|
|
|
|
|
} |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
=head1 ACCESSOR METHOD |
|
296
|
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
=head2 email |
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
Get/Set login email |
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
Example: |
|
302
|
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
$buzz->email("your email"); |
|
304
|
|
|
|
|
|
|
my $email = $buzz->email; |
|
305
|
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
=head2 password |
|
307
|
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
Get/Set login password |
|
309
|
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
Example: |
|
311
|
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
$buzz->password("your password"); |
|
313
|
|
|
|
|
|
|
my $password = $buzz->password; |
|
314
|
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
=head2 ua |
|
316
|
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
Get LWP::UserAgent instance(Readonly) |
|
318
|
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
Example: |
|
320
|
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
# LWP::UserAgent::timeout |
|
322
|
|
|
|
|
|
|
$buzz->ua->timeout(30); |
|
323
|
|
|
|
|
|
|
# LWP::UserAgent::env_proxy |
|
324
|
|
|
|
|
|
|
$buzz->ua->env_proxy; |
|
325
|
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
=cut |
|
327
|
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
1; |
|
329
|
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
__END__ |