Changeset 4255 for lang/perl/WWW-HatenaDiary
- Timestamp:
- 01/09/08 10:49:21 (5 years ago)
- Location:
- lang/perl/WWW-HatenaDiary/trunk
- Files:
-
- 3 modified
-
Makefile.PL (modified) (1 diff)
-
README (modified) (2 diffs)
-
lib/WWW/HatenaDiary.pm (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/WWW-HatenaDiary/trunk/Makefile.PL
r3939 r4255 10 10 Getopt::Long 11 11 Digest::MD5 12 Text::Hatena 13 Web::Scraper 14 WWW::Mechanize 15 JSON::Syck 12 16 /); 13 17 -
lang/perl/WWW-HatenaDiary/trunk/README
r3939 r4255 3 3 INSTALLATION 4 4 5 WWW::HatenaDiary installation is straightforward. If your CPAN shell is set up,6 you should just be able to do5 WWW::HatenaDiary installation is straightforward. If your CPAN shell 6 is set up, you should just be able to do 7 7 8 8 % cpan WWW::HatenaDiary … … 25 25 to read the documentation online with your favorite pager. 26 26 27 AUTHOR 28 27 29 Tokuhiro Matsuno 30 Kentaro Kuribayashi -
lang/perl/WWW-HatenaDiary/trunk/lib/WWW/HatenaDiary.pm
r4239 r4255 76 76 77 77 my $entry = Load($self->{mech}->content); 78 79 78 if($args->{format}) { 80 79 $entry->{body} = Text::Hatena->parse($entry->{body}); 81 80 } 82 83 81 $entry; 84 82 } … … 97 95 carp "Invalid ymd format: $args->{date}. YYYY-MM-DD formatted date is required."; 98 96 } 99 }100 101 # TODO: implement retrieve_month method.102 sub retrieve_month {103 my ($self, $args) = @_;104 die "Not implemented yet";105 97 } 106 98 … … 190 182 =head1 NAME 191 183 192 WWW::HatenaDiary - 184 WWW::HatenaDiary - CRUD interface to Hatena::Diary 193 185 194 186 =head1 SYNOPSIS … … 196 188 use WWW::HatenaDiary; 197 189 198 my $ hatena= WWW::HatenaDiary->new({190 my $diary = WWW::HatenaDiary->new({ 199 191 login_id => $login_id, 200 192 login_pw => $login_pw, … … 202 194 203 195 # Create 204 my $uri = $hatena->create({ 205 title => 'mixi', 206 body => 'boofy', 196 my $edit_uri = $diary->create({ 197 title => $title, 198 body => $body, 199 }); 200 201 # Retrieve 202 my $post = $diary->retrieve({ 203 uri => $edit_uri, 204 }) 205 206 my $day_body = $diary->retrieve_day({ 207 date => $date, # $date must be YYYY-MM-DD formatted string 207 208 }); 208 209 209 210 # Update 210 $uri = $hatena->update({ 211 uri => $uri, 212 title => 'Update: mixi', 213 body => "Update: boofy", 214 }); 215 216 $hatena->update_day({date => '2008-01-01', body => <<'EOS'}); 217 * title 1 218 body 1 219 220 * title 2 221 body 2 222 EOS 223 224 # Retrieve 225 my $body = $hatena->retrieve($uri) 226 my $day_body = $hatena->retrieve_day({date => '2008-01-01'}); 211 $edit_uri = $diary->update({ 212 uri => $edit_uri, 213 title => $new_title, 214 body => $new_body, 215 }); 216 217 $diary->update_day({ 218 date => $date, # $date must be YYYY-MM-DD formatted string 219 body => $new_body, 220 }); 227 221 228 222 # Delete 229 $hatena->delete($uri); # not implemented yet 230 $hatena->delete_day({date => $date}); 223 $diary->delete({ # not implemented yet 224 uri => $edit_uri, 225 }); 226 227 $diary->delete_day({, 228 date => $date, # $date must be YYYY-MM-DD formatted string 229 }); 231 230 232 231 =head1 DESCRIPTION 233 232 234 WWW::HatenaDiary is 235 236 =head1 THANKS 237 238 typester++ some codes copied from Fuse::Hatena. 233 WWW::HatenaDiary provides a CRUD interface to Hatena::Diary, aiming to 234 help you efficiently communicate with the service with programatical 235 ways. 236 237 This module is, so far, for those who want to write some tools not 238 only to retrieve data from diaries, but also to create/update/delete 239 the posts at the same time. Which is why I adopted the way as if this 240 module treats such API like AtomPP, and this module retrieves and 241 returns raw formatted post content not a data already converted to 242 HTML. 243 244 =head1 METHODS 245 246 =head2 new ( I<\%args> ) 247 248 =over 4 249 250 my $diary = WWW::HatenaDiary->new({ 251 login_id => $login_id, 252 login_pw => $login_pw, 253 }); 254 255 Creates and returns a new WWW::HatenaDiary object. Both C<login_id> 256 and C<login_pw> are required. 257 258 =back 259 260 =head2 create ( I<\%args> ) 261 262 =over 4 263 264 my $edit_uri = $diary->create({ 265 title => $title, 266 body => $body, 267 }); 268 269 Creates a new post and returns a URI as a L<URI> object for you to 270 retrieve/update/delete the post later on. 271 272 =back 273 274 =head2 retrieve ( I<\%args> ) 275 276 =over 4 277 278 my $post = $diary->retrieve({ 279 uri => $edit_uri, 280 }) 281 282 Retrieves the post for C<uri>. The return value C<$post> is a 283 reference to a hash which contains the fields as follows: 284 285 =item title 286 287 Title of the post. 288 289 =item body 290 291 Content of the post as a raw formatted data. 292 293 =item editable 294 295 Flag if you're authorized to edit the post or not. 296 297 =item rkm 298 299 Token which is internally used when this module sends a request. You 300 needn't care about it. 301 302 =back 303 304 =head2 retrieve_day ( I<\%args> ) 305 306 =over 4 307 308 my $day_body = $diary->retrieve_day({ 309 date => $date, # $date must be YYYY-MM-DD formatted string 310 }); 311 312 Retrieves the post body for C<date>. So far, this method gets only the 313 raw formatted content of the post. 314 315 =back 316 317 =head2 update ( I<\%args> ) 318 319 =over 4 320 321 $edit_uri = $diary->update({ 322 uri => $edit_uri, 323 title => $new_title, 324 body => $new_body, 325 }); 326 327 Updates the post for C<uri> and returns the URI as a L<URI> object for 328 you to do with the post still more. 329 330 =back 331 332 =head2 update_day ( I<\%args> ) 333 334 =over 4 335 336 $diary->update_day({ 337 date => $date, # $date must be YYYY-MM-DD formatted string 338 body => $new_body, 339 }); 340 341 Updates the whole posts of the C<date>. C<body> must be a 342 Hatena::Diary style formatted data, that is, this method emulates the 343 way when you write a post on your browser and send it via the form. 344 345 =back 346 347 =head2 delete ( I<\%args> ) **NOT IMPLEMENTED YET** 348 349 =over 4 350 351 $diary->delete({ 352 uri => $edit_uri, 353 }); 354 355 Deletes the post for C<uri>. 356 357 =back 358 359 =head2 delete_day ( I<\%args> ) 360 361 =over 4 362 363 $diary->delete_day({ 364 date => $date, # $date must be YYYY-MM-DD formatted string 365 }); 366 367 Deletes the whole posts of the C<date>. 368 369 =back 370 371 =head1 SEE ALSO 372 373 =over 4 374 375 =item * Hatena::Diary (Japanese) 376 377 L<http://d.hatena.ne.jp/> 378 379 =back 380 381 =head1 ACKNOWLEDGMENT 382 383 typester++ for some codes copied from Fuse::Hatena. 239 384 240 385 =head1 AUTHOR … … 243 388 244 389 Kentaro Kuribayashi E<lt>kentarok aaaatttt gmail dotottto commmmmE<gt> 245 246 =head1 SEE ALSO247 390 248 391 =head1 LICENSE
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)