roryne has asked for the wisdom of the Perl Monks concerning the following question:

I'm writing a little script that is required to log in to Yahoo's mail and clear out the bulk folder. The problem is I can't seem to get it to log in...

my $request = $ua->get("https://login.yahoo.com/config/login?.src=fpct +x&.done=http://www.yahoo.com"); $cookie_jar->extract_cookies($request);

This part works fine, it grabs the cookies and writes out to a file like it's supposed to (under HTTP::Cookies). It's when I try and use a POST string to actually do the logging in that it just won't work.
$postString = 'https://login.yahoo.com/config/login?' . "$postString"; my $request = $ua->get($postString);

There's my login string (it works manually), but when I dump the page content into an html file and open it, it tells me my browser is blocking cookies.
I've looked all over cpan.org and different modules documentation and I just can't seem to figure out exactly what I'm supposed to do :( Please help me out!

Replies are listed 'Best First'.
Re: Small problem with handling cookies
by Cody Pendant (Prior) on Oct 16, 2007 at 08:38 UTC
    Use WWW:Mechanize -- life's too short.

    Seriously, try with Mechanize and get back to us if that doesn't work.



    Nobody says perl looks like line-noise any more
    kids today don't know what line-noise IS ...
Re: Small problem with handling cookies
by moritz (Cardinal) on Oct 16, 2007 at 08:33 UTC
    It seems to me you're not sending the cookie back to the server. Or do you? You're not showing the code that does it.

    And it seems you are sending POST parameters in the URL (ie treating them as GET), instead of using $ua->post to actually post them.

Re: Small problem with handling cookies
by Gangabass (Vicar) on Oct 16, 2007 at 08:39 UTC

    Please, show more code. Also take a look to WWW::Mechanize.

Re: Small problem with handling cookies
by roryne (Initiate) on Oct 16, 2007 at 08:48 UTC
    http://roryne.com/mail.txt
    Before I go look at www::mechanize, there's all my code so far. I'm very new to perl and I know it's sloppy and not the most efficient, but eh, it works (almost :|).
      As I wrote before, it uses a get request when a post is expected. But WWW::Mechanize is really the better idea.
        Try running it how it is right now and then change it to a post. When you open the html file after a GET, there's a problem with the login (cookies being the problem). If you do it with a POST, you get absolutely no error and it acts like it didn't do anything.
        I'll look at WWW::Mechanize tomorrow, it's 4am and I have class at 9. Thanks for the heads up on the module.