Facebook login via Perl WWW::Mechanize, login error "Cookies Required" -


this question has answer here:

i have perl script run in strawberry perl in login facebook using www::mechanize. short background, use script automate occasional "leaderboard" fun little game invented played among group of friends. assign points based upon posts, , objective earn points. simple. script complete, , it's worked me in past (i last ran 4 days ago). however, unable login facebook today. dumped content after form submission html file, , appears i've returned login screen red error box:

cookies required

cookies not enabled on browser. please enable cookies in browser preferences continue.

from understand, www::mechanize features automatic cookies -- in other words default constructor, bot should accepting cookies. cookies should enabled browser. should not see screen, right?

i've read , experimented www:mechanize , http::cookies, no matter try (fooling around cookie jar every way), cannot past "cookies required" error.

this code without experimental fluff, simple.

use www::mechanize;  $mech = www::mechanize->new(); $mech->get("https://www.facebook.com/login.php"); $mech->submit_form(     fields => {         email => '<my email here>',         pass => '<my password here>',     } );  open($out, ">",  "output_page.html") or die "can't open output_page.html: $!"; print $out $mech->content; 

capture session of logging in browser (if you're using firefox can use firebug, , check http headers set - how-to. set same headers in script, including user agent. check if same cookies set. may end below:

use strict; use warnings; use www::mechanize; use http::cookies;  $cookie_jar = http::cookies->new(      hide_cookie2 => 1,  );  $mech = www::mechanize->new(     cookie_jar => $cookie_jar, );  $mech->agent_alias('windows mozilla');  $mech->add_header( 'connection'      => 'keep-alive' ); $mech->add_header( 'accept-language' => 'en-gb,en;q=0.5' ); $mech->add_header( 'accept-encoding' => 'gzip, deflate' ); $mech->add_header( 'accept' =>       'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ); 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -