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 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.
mech_opt
username
password
is_loggedin
com field is optional, which will be required if you login to hatena.com.
com
labo field is optional, which will be required if you login to hatelabo.jp.
labo
nologin field is optional, which will be required if you do not login new method.
nologin
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.
if(!$session->is_loggedin) { ... }
Checks if $session object already logs in to Hatena.
$session
$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.
new
$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>
Hatena
http://www.hatena.com/
WWW::Mechanize
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.
To install WWW::HatenaLogin, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::HatenaLogin
CPAN shell
perl -MCPAN -e shell install WWW::HatenaLogin
For more information on module installation, please visit the detailed CPAN module installation guide.