DISQUS

Developer On Line: Using Perl Against Facebook - Part I: Login

  • Wael · 1 year ago
    I'm getting the following errors:

    syntax error at C:\FB\script.pl line 12, near "'email')"
    Missing right curly or square bracket at C:\FB\script.pl line 40, at end of line

    I downloaded ActivePerl and am trying the script
    I might be doing smthg wrong coz am new to perl script.. I have knowledge in vb.net but couldnt find smthg similar written in vb.net
  • panefsky · 1 year ago
    Ok, this is my bad. It was a weird typo:
    WRONG is:
    $postLoginData{'email')=$email;

    CORRECT is
    $postLoginData{'email'}=$email;

    The curlies {} have to much
  • Wael · 1 year ago
    After figuring out how to download the additional packages and adding these two lines at the beginning of the script:
    use HTTP::Cookies;
    use LWP::UserAgent;

    Now am getting a new error:
    Can't call method "content" on an undefined value at C:\FB\script.pl line 35

    Any ideas!?
  • panefsky · 1 year ago
    if your line 35 is
    $response->content =~ /Incorrect Email/

    then probably the $response variable is not initialized properly.
    Did you install Crypt::SSLeay? This will enable https for Perl.
  • Just Another Perl Sub-Hacker · 10 months ago
    you can't ask $response for its "content" method because $response isn't getting set first.

    You need to add "$response = " to the front of the first two $browser->get() and $browser->post() lines. (As a comparison, the last line, the GET of home.php, does it correctly.)
  • narasimha · 1 year ago
    Hi
    thanks fr ur post.
    can u tell me how to work with IE 7.0
    and how to get the inf fr
    'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6';
  • abay · 1 year ago
    i really want to get on this site
  • Ali · 11 months ago
    me too .
  • panefsky · 11 months ago
    Try the Part II at http://developeronline.blogspot.com/2008/10/usi...

    See the comments section
  • Jayme · 1 year ago
    Is it possible to see the entire sample code that you mention above ?
    "The final Perl script has about 500 lines of code and can send messages, retrieve inbox and chat among others! ?

    Thanks for the help and have a Happy New year!
  • smart · 11 months ago
    i need to login at facebook.com
  • erika · 9 months ago
    why i cant log in to facebook???
  • erika · 9 months ago
    it always say "Incorrect Email/Password Combination
    Facebook passwords are case sensitive. Please check your CAPS lock key. You may also try clearing your browser's cache and cookies by following these instructions."

    even my password and email is correct...
  • panefsky · 9 months ago
    Go to Part II and see the comments. You will get your answer there.

    http://developeronline.blogspot.com/2008/10/usi...
  • mark · 8 months ago
    Ive got one. I can login to facebook on multiple computers but, the one i use everyday now seems to have a virus preventing me logging into facebook. I attempt to login with my user id or my friends and it goes straight to "page cannot be displayed"

    No AV or malware program has picked anything up. I have deleted some .exe and .dll to no avale
  • Cuboidgraphix · 2 months ago
    Anybody has a complete script? I'm having problems with this one.
  • Sophie Vierra · 1 month ago
    Hi,
    I am Programmer with Chessboss.com. Chessboss.com is absolutely FREE chess server where you can play chess,create your own tournament with players online. No Gambling and explicit talk. This website is purely meant to increase the fan-base of chess and for entertainment. I Need your help to promote the FREE chess server around the world. I would like to be on your blog as i found it a useful and informative resource. By adding chessboss.com you will recognized and added as a top resource on our chess server. I really believe in FREE flow of information. I have included the code and title.

    Please email me back with subject line of your URL for the featured resource code. This is to avoid spam and to make sure you get the award.

    I hope you understand and co-operate with us.

    Thank you,
    Sophie Vierra
    Programmer
    www.chessboss.com.
  • ftumsh · 3 weeks ago
    #! /usr/bin/perl -w
    use strict;
    use diagnostics;

    use HTTP::Cookies;
    use LWP::UserAgent;

    use Data::Dumper;

    my $email; #stores our mail
    my $password; #stores our password
    my $user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6';

    $email = 'foo'; #read the login e-mail
    $password='bar'; #read the password

    chomp($email); #remove last line
    chomp($password);

    my %postLoginData; #necessary post data for login
    $postLoginData{'email'}=$email;
    $postLoginData{'pass'}=$password;
    $postLoginData{'persistent'}=1;
    $postLoginData{'login'}='Login';

    #set the headers, let's make this a Firefox browser!
    my @header = ('Referer'=>'http://www.facebook.com', 'User-Agent'=>$user_agent);

    my $cookie_jar = HTTP::Cookies->new(file=>'fbkCookies.dat',autosave=>1, ignore_discard=>1);

    my $ua = LWP::UserAgent->new; #init browser
    $ua->cookie_jar($cookie_jar);

    $ua->get('http://www.facebook.com/login.php', @header);

    #here we actually login!
    my $r = $ua->post('https://login.facebook.com/login.php', \%postLoginData, @header);

    # print 'Content: '.$r->decoded_content;

    #was login successful?
    if($r->content =~ /Incorrect Email/) {
    print "Login Failed...Quitting..\n";
    }
    else {
    print "..and we are in!";
    #let's go to the homepage
    $r = $ua->get('http://www.facebook.com/home.php',@header);
    }