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

NAME

WWW::Yahoo::Login - Login and out of Yahoo Web Sites

SYNOPSIS

Lots of people have data in Yahoo. Some of them are Perl programmers who might want to use the scripty goodness of Perl to access that data. WWW::Yahoo::Login takes the pain out of the first step.

  use WWW::Yahoo::Login qw( login logout );
  use WWW::Mechanize;

  my $mech = WWW::Mechanize->new();

  $resp = login(
      mech    =>  $mech,
      uri     =>  'http://mail.yahoo.com/',
      user    =>  'a_yahoo_user',
      pass    =>  'asecret',
  );

  if ($resp) {
    print $mech->content;
  } else {
    warn $WWW::Yahoo::Login::ERROR;
  }

  # do some things
    
  unless ( logout(mech => $mech) ) {
    warn $WWW::Yahoo::Login::ERROR;
  }

DESCRIPTION

WWW::Yahoo::Login provides a login and a logout function, neither of which are exported by default.

login

  login(
    mech    =>  $mech,      
    uri     =>  'http://address.yahoo.com/', 
    user    =>  'a_user',  
    pass    =>  'secret', 
    sleep   =>  1,       
  );

login takes 5 parameters:

mech

A WWW::Mechanize object.

uri

The URI of the Yahoo page to login or out of.

user

The Yahoo ID to use when signing in.

pass

The password for the user.

sleep

This is optional and defines how many second to sleep between requests. If not supplied then the default of 5 seconds is used. It's generally considered the polite thing to do for a bot to sleep for a few seconds between requests.

back

login returns 1 on success or undef on error. If there is an error $WWW::Yahoo::Login::ERROR is set. See below for possible error messages.

logout

  logout( mech => $mech );

logout only accepts a mech paramater. As with login it returns 1 on success and undef on failure. $WWW::Yahoo::Login::ERROR contains any error.

ERRORS

The possible error messages that WWW::Yahoo::Login can generate are:

Required params missing: [list of missing params]

You didn't supply all the paramaters that either login or logout require

Failed to fetch [uri]: [error message]

The uri in question could not be fetched.

Login failed: You are already logged in

As far as login can tell you are already logged in. In practice it means there was a sign out link on the page.

login couldn't find either the Yahoo login form or a sign on link on the page.

Form submission failed: [error message]

There was some sort of problem submitting the login form.

Failed to follow redirect: [error message]

Somewhere amongst the fleet of redirects that takes place in the Yahoo login process there was a problem.

Failed to follow Javascript redirect: [error message]

Another type of redirect problem.

Login failed: Invalid Yahoo ID

Exactly what it says.

Login failed: Invalid Password

Exactly what it says.

Failed to log out

logout couldn't find a sign out link on the page.

CAVEATS

WWW::Yahoo::Login relies on WWW::Mechanize. It assumes you are going to use WWW::Mechanize for all your access to Yahoo.

I've only tested it on perl 5.6.1 on Debian i386.

SUPPORT

author email.

AUTHOR

        Struan Donald
        modules@exo.org.uk
        http://www.exo.org.uk/code/

COPYRIGHT

Copyright (C) 2003 Struan Donald. All rights reserved.

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

SEE ALSO

perl(1), WWW::Mechanize.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 209:

You forgot a '=back' before '=head2'