in reply to How can I use LWP to log into digest-auth site and do post() (converting from PHP CURL)

What am I doing wrong?

Except for posting a password on a public website? ;) You aren't using strict and warnings. You are using C style for loop (not really wrong, but not very perlish). You're adding "\n\n" to the result returned by the credentials method, which is useless. And the first argument of the credentials is wrong. Here's a working example:

use 5.010; use strict; use warnings; use LWP::UserAgent; my @sites = ( "searchjid.usa.np.community.playstation.net", "searchjid.eu.np.community.playstation.net", "searchjid.jpn.np.community.playstation.net", ); my $path = "/basic_view/func/search_jid"; my $user = "c7y-basic01"; my $pass = "A9QTbosh0W0D^{7467l-n_>2Y%JG^v>o"; for (@sites) { my $browser = LWP::UserAgent->new; $browser->agent("PS3Community-agent/1.0.0 libhttp/1.0.0"); $browser->credentials( "$_:80", "c7y-basic", $user => $pass ); say $browser->head( "http://" . $_ . $path )->as_string; }
  • Comment on Re: How can I use LWP to log into digest-auth site and do post() (converting from PHP CURL)
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: How can I use LWP to log into digest-auth site and do post() (converting from PHP CURL)
by fgsfds100 (Initiate) on Apr 22, 2012 at 12:52 UTC

    Thank you so much, this worked perfectly! I don't think I ever would have got this working by myself, but I'm glad I was fairly close.

    And yes, I realize posting that password wasn't a great idea but I felt that, apart from being necessary to truly see if the program could connect to that site specifically, it doesn't grant access to anything significant and it was already included in the PHP code on the site I linked to. Also thanks for the tip on the for loop.