WebService::Hatena::Diary - A Perl Interface for Hatena::Diary AtomPub API


WebService-Hatena-Diary documentation  | view source Contained in the WebService-Hatena-Diary distribution.

Index


NAME

Top

WebService::Hatena::Diary - A Perl Interface for Hatena::Diary AtomPub API

SYNOPSIS

Top

  use WebService::Hatena::Diary;

  my $diary = WebService::Hatena::Diary->new({
      username  => $username,
      password  => $password,
  });
  $diary->ua->timeout(10) # set ua option

  # list
  my @entries = $diary->list;

  # create
  my $edit_uri = $diary->create({
      title   => $title,
      content => $content,
  });

  # create on specified date
  $edit_uri = $diary->create({
      date    => $date, # YYYY-MM-DD
      title   => $title,
      content => $content,
  });

  # retrieve
  my $entry = $diary->retrieve($edit_uri);
  print $entry->{date};
  print $entry->{title};
  print $entry->{content};
  print $entry->{hatena_syntax};

  # update
  $diary->update($edit_uri, {
      title   => $new_title,
      content => $new_content,
  });

  # delete
  $diary->delete($edit_uri);




  # draft mode
  $diary = WebService::Hatena::Diary->new({
      mode      => 'draft',
      username  => $username,
      password  => $password,
  });

  # publish (draft mode only)
  $diary->publish($edit_uri);

DESCRIPTION

Top

WebService::Hatena::Diary is a simple wrapper of Hatena::Diary AtomPub API. This provides CRUD interfaces for Hatena::Diary and it's draft entries.

METHOD

Top

new ( \%args )

  my $diary = WebService::Hatena::Diary->new({
      username  => $username,
      dusername => $dusername,
      password  => $password,
      mode      => $mode,
  });

Create a WebService::Hatena::Diary object.

*

username

Your Hatena id.

*

dusername (Optional)

Diary name that you want to manipulate. Default is username.

*

password

Password for your Hatena id.

*

mode (Optional)

API mode ( blog | draft ). Default is blog.

ua

  $diary->ua;

  Returns a UserAgent of this API.




errstr

  $diary->errstr;

Returns a error messages of the last error.

list

  my @entries = $diary->list;

Returns a LIST of entries of the specified (blog|draft). Each entry has values blow as a HASH object:

create ( \%args )

  my $edit_uri = $diary->create({
      title   => $title,
      content => $content,
      date    => $date,
  });

Create a new entry of the specified (blog|draft). Returns Edit URI of a created entry if succeed.

You have to pass date on a YYYY-MM-DD format.

retrieve ( $edit_uri )

  my $entry = $diary->retrieve($edit_uri);

Returns a entry specified by an Edit URI as a HASH object like below:

update ( $edit_uri, \%args )

  $diary->update($edit_uri, {
      title   => $title,
      content => $content,
  });

Update a entry specified by an Edit URI. Returns 1 if succeed.

delete ( $edit_uri )

  $diary->delete($edit_uri);

Delete a entry specified by an Edit URI. Returns 1 if succeed.

publish ( $edit_uri )

  $diary->publish($edit_uri);

Publish a draft entry specified by an Edit URI. Returns 1 if succeed.

If you publish a draft entry, the entry will be deleted from draft, and a new blog entry will be created.

DEVELOPMENT

Top

If you want to see latest version of this module, please see https://github.com/hakobe/webservice-hatena-diary/tree

AUTHOR

Top

Yohei Fushii <hakobe@gmail.com>

LICENSE

Top

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

Top

*

http://d.hatena.ne.jp

*

http://d.hatena.ne.jp/keyword/%A4%CF%A4%C6%A4%CA%A5%C0%A5%A4%A5%A2%A5%EA%A1%BCAtomPub

*

WWW::HatenaDiary

*

XML::Atom


WebService-Hatena-Diary documentation  | view source Contained in the WebService-Hatena-Diary distribution.