I have no idea if it works, but the copyright on the module is 2003 so unless Yahoo has changed stuff recently it may still work.
From the Caveats section:
============= CAVEATS
There is an issue somewhere that prevents https redirects from succeeding. Until this is fixed, the login procedure WILL expose the username and password in plain text over the network.
=============
Now, if you're doing this to try and learn LWP, then you've got a long road ahead of you if you want to logon to Yahoo Mail. You're going to have to examine the Yahoo Mail logon page and emulate its communication to the Yahoo servers.
Looking at the HTML code for http://mail.yahoo.com, there are at least two possibilities for logging in to Yahoo Mail ( see the hash() function in the HTML page for http://mail.yahoo.com):
1. If your browser supports JavaScript/JScript, then the page will append all the form's parameters together, including a MD5-hashed password + challenge value on to the login URL and change the page to that new URL via "location.href = url;", i.e. GETing the new, really long URL. Then the script code cancels the form submit.
2. If your browser isn't running Javascript/JScript then the code will go ahead with the form submit to a https URL. The https URL looks like it has a challenge/salt/cookie value on the end.
I was only able to programmatically login to Yahoo Mail via method #1. It wasn't totally programmatic since I had to copy the generated URL into my perl script to do the logon.
It shouldn't take too much to get http://mail.yahoo.com, extract the relevant form parameters (there are two salt values which seem to change everytime you grab the mail.yahoo.com page), encode the form parameters the same way that the hash() function does, and then do a GET on that new URL.
Your code is trying something similar to #2 but with the wrong URL.
I believe your code should have:
use HTTP::Request::Common;
instead of:
use HTTP::Request;
otherwise, I get an error when I try to run the script.
Once I fix that problem and run the script, Yahoo returns a 302 code for the POST request.
Looking at the Mail::WebMail::Yahoo module, it seems Yahoo uses 302's to redirect to another page.
Adding in some code to check for the 302 result code and to follow the Location URL in the response, if 302 is found, Yahoo sends me to a "My Yahoo"-you've-got-an-old-page-click-on-this-link-to-refresh page.
That's about all the time I've got to spend on this question. Good luck.
J
From: Terry <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: problem with cookies Date: Thu, 24 Jul 2003 07:48:23 -0700 (PDT)
Hello,
I am having issues with cookies being set correctly (i think).
I am simply trying to log into yahoo mail. Here is my code:
#!/usr/bin/perl
use strict; use LWP; use HTTP::Cookies; use HTTP::Request;
use vars qw($ua $req $res $username $passwd $url $cookie_jar);
$username = 'jomama'; $passwd = 'foo'; $cookie_jar = HTTP::Cookies->new( file => "$ENV{'HOME'}/.lwp_cookies.dat", autosave => 1, );
$ua = LWP::UserAgent->new; $ua->agent('Mozilla/5.0'); $ua->cookie_jar($cookie_jar); $res = $ua->request(POST 'http://login.yahoo.com/config/login', [ login => "$username", passwd => "$passwd", ] );
if ($res->is_success) { print $res->content; } else { print "Damn\n"; }
Everytime I get 'Damn' returned from the above code. I have tried this on a similar login form that I can see the server logs of and it says that the browser does not support cookies so that is why I am guessing the problem I am having has to do with cookies.
Thanks for helping a perl beginner.
__________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com
_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail
