Facebook search with cURL , where is the problem ?

Discussion in 'PHP' started by CasTex, Sep 29, 2010.

  1. #1
    This script logins the facebook and gather some data (not important) from search, but however, its not working. Where is my mistake ? (Login is working, but gathering info from search results, isnt.)

    <?
    
    $first_name = 'Eda';
    $login_email = 'bodrumlukardes@hotmail.com';
    $login_pass = 'mypassword';
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://login.facebook.com/login.php?m&amp;next=http%3A%2F%2Fm.facebook.com%2Fhome.php');
    curl_setopt($ch, CURLOPT_POSTFIELDS,'email='.urlencode($login_email).'&pass='.urlencode($login_pass).'&login=Login');
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_COOKIEJAR, "my_cookies.txt");
    curl_setopt($ch, CURLOPT_COOKIEFILE, "my_cookies.txt");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
    curl_exec($ch);
    
    curl_setopt($ch, CURLOPT_POST, 0);
    curl_setopt($ch, CURLOPT_URL, 'http://www.facebook.com/search/?init=quick&q=bodrumlukardes%40hotmail.com');
    $page = curl_exec($ch);
    
    curl_setopt($ch, CURLOPT_POST, 1);
    
    preg_match_all('#<td(.*?)</td>#si', $page, $aldim8);
    echo $aldim8[1][0];
    
    
    ?>
    PHP:
     
    CasTex, Sep 29, 2010 IP
  2. gapz101

    gapz101 Well-Known Member

    Messages:
    524
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    150
    #2
    of course, it is not the way to login to facebook
     
    gapz101, Sep 29, 2010 IP