Changeset 811

Show
Ignore:
Timestamp:
05/24/06 20:00:05
Author:
miyagawa
Message:

Subscription::HatenaRSS now uses public OPML URL of HatenaRSS, and uses new Cookies sharing feature if available.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger/Plugin/Subscription/HatenaRSS.pm

    r810 r811  
    1818 
    1919    my $username = $self->conf->{username} 
    20         or $context->error('username is missing'); 
     20        or $context->error("username is missing"); 
    2121 
    22     my $start = "https://www.hatena.ne.jp/login?backurl=http%3A%2F%2Fr.hatena.ne.jp%2F"; 
     22    my $mech = Plagger::Mechanize->new(cookie_jar => $self->cookie_jar); 
     23    $mech->get("http://r.hatena.ne.jp/$username/opml"); 
    2324 
    24     # support cookie_jar 
    25     my $mech = Plagger::Mechanize->new; 
    26     $mech->get($start); 
     25    if ($mech->content !~ /<opml version/) { 
     26        $mech->get("https://www.hatena.ne.jp/login?backurl=http%3A%2F%2Fr.hatena.ne.jp%2F"); 
     27        $mech->submit_form( 
     28            fields => { 
     29                key      => $username, 
     30                password => $self->conf->{password}, 
     31            }, 
     32        ); 
    2733 
    28     $mech->submit_form( 
    29         fields => { 
    30             key      => $username, 
    31             password => $self->conf->{password}, 
    32         }, 
    33     ); 
    34  
    35     if ( $mech->content =~ m!<div class="error">! ) { 
    36         $context->log(error => "Login to HatenaRSS failed."); 
    37         return; 
     34        if ( $mech->content =~ m!<div class="error">! ) { 
     35            $context->log(error => "Login to HatenaRSS failed."); 
     36            return; 
     37        } 
    3838    } 
    3939 
    4040    $context->log(info => "Login to HatenaRSS succeed."); 
    41  
    42     $mech->get("http://r.hatena.ne.jp/$username/config"); 
    43     $mech->submit_form(form_name => 'opmlexport'); 
    4441 
    4542    my $opml = $mech->content; 
     
    6259    config: 
    6360      username: example 
    64       password: xxxxxxxx 
    6561 
    6662=head1 DESCRIPTION 
    6763 
    6864This plugin creates Subscription by fetching Hatena RSS 
    69 L<http://r.hatena.ne.jp> OPML by HTTP. Since Hatena RSS OPML export 
    70 requires login state, it uses WWW::Mechanize module to emulate the 
    71 browser's login authentication procedure. 
     65L<http://r.hatena.ne.jp> OPML by HTTP. 
     66 
     67If your OPML is shared public (which is default), you don't have to 
     68pass password to the config. Also, even if you OPML is private, you 
     69can share Cookies with your favorite browser like Firefox, using 
     70 
     71  global: 
     72    user_agent: 
     73      cookies: /path/to/cookies.txt 
     74 
     75so that you don't have to pass password to the config, again. 
    7276 
    7377=head1 AUTHOR