
WWW::HatenaLogin - login/logout interface to Hatena

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;

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.

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 omitusernameandpassword. Even in that case, you might want to check if the user agent already logs in to Hatena usingis_loggedinmethod below.
comfield is optional, which will be required if you login to hatena.com.
labofield is optional, which will be required if you login to hatelabo.jp.
nologinfield is optional, which will be required if you do not login new method.
mech_optfield 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.
if(!$session->is_loggedin) { ... }Checks if
$sessionobject already logs in to Hatena.
$diary->login({ username => $username, password => $password, });Logs in to Hatena::Diary using
usernameandpassword. If eitherusernameorpasswordisn't passed into this method, the values which are passed intonewmethod above will be used.
$session->logout;Logout by Hatena.
$session->mech;return to WWW::Mechanize object.
$session->cookie_jar;return to HTTP::Cookies object. this method same to $session->mech->cookie_jar;
$session->session_id;return to session id. key in cookie is a value of rk.
$session->login_uri;return to login uri.
$session->logout_uri;return to logout uri.
$session->username; $session->username('new_username');username accessor

Kazuhiro Osawa <ko@yappo.ne.jp>


some codes copied from WWW::HatenaDiary.

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