The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

WWW::HatenaLogin - login/logout interface to Hatena

SYNOPSIS

  use WWW::HatenaLogin;

  # new login
  my $session = WWW::HatenaLogin->new({
      username => 'username',
      password => 'password',
  });

  # login to hatena.com  (optional)
  my $session = WWW::HatenaLogin->new({
      username => 'username',
      password => 'password',
      com      => 1,
  });

  # login to hatelabo.jp  (optional)
  my $session = WWW::HatenaLogin->new({
      username => 'username',
      password => 'password',
      labo     => 1,
  });

  # do not login with new method
  my $session = WWW::HatenaLogin->new({
      username => 'username',
      password => 'password',
      nologin  => 1,
  });

  # WWW::Mechanize option (optional)
  my $session = WWW::HatenaLogin->new({
      username => 'username',
      password => 'password',
      mech_opt => {
          timeout    => $timeout,
          cookie_jar => HTTP::Cookies->new(...),
      },
  });

  # logout
  $session->logout;

  # login
  $session->login;

  # Check if already logged in to Hatena
  # If you have a valid cookie, you can omit this process
  unless ($session->is_loggedin) {
      $session->login;
  }

  # get session id
  $session->session_id;

  # get cookie_jar
  $session->cookie_jar;

  # get WWW::Mechanize object
  $session->mech;

DESCRIPTION

WWW::HatenaLogin login and logout interface to Hatena. this module is very simple.

You can easily recycle login data the following WWW::Mechanize object and Cookie data. Please refer to the mech method and the cookie_jar method.

AUTHOR

new ( [\%args] )

      my $session = WWW::HatenaLogin->new({
          username => $username,
          password => $password,
          mech_opt => {
              timeout    => $timeout,
              cookie_jar => HTTP::Cookies->new(...),
          },
          com  => 1, # use to hatena.com server
          labo => 1, # use to hatelabo.jp server
          nologin => 1, # do not login with new method
      });

    Creates and returns a new WWW::HatenaLogin object. If you have a valid cookie and pass it into this method as one of mech_opt, you can omit username and password. Even in that case, you might want to check if the user agent already logs in to Hatena using is_loggedin method below.

    com field is optional, which will be required if you login to hatena.com.

    labo field is optional, which will be required if you login to hatelabo.jp.

    nologin field is optional, which will be required if you do not login new method.

    mech_opt field is also optional. You can use it to customize the behavior of this module in the way you like. See the POD of WWW::Mechanize for more details.

is_loggedin ()

      if(!$session->is_loggedin) {
          ...
      }

    Checks if $session object already logs in to Hatena.

login ( [\%args] )

      $diary->login({
          username => $username,
          password => $password,
      });

    Logs in to Hatena::Diary using username and password. If either username or password isn't passed into this method, the values which are passed into new method above will be used.

logout ()

      $session->logout;

    Logout by Hatena.

mech ()

      $session->cookie_jar;

    return to HTTP::Cookies object. this method same to $session->mech->cookie_jar;

session_id ()

      $session->session_id;

    return to session id. key in cookie is a value of rk.

login_uri ()

      $session->login_uri;

    return to login uri.

logout_uri ()

      $session->logout_uri;

    return to logout uri.

username ('username')

      $session->username;
      $session->username('new_username');

    username accessor

AUTHOR

Kazuhiro Osawa <ko@yappo.ne.jp>

SEE ALSO

ACKNOWLEDGMENT

some codes copied from WWW::HatenaDiary.

LICENSE

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