2016-06-21 50 views
1

我想使用laravel中的goutte登錄Facebook。 他們是登錄到github的文檔,但我想登錄到facebook並獲取頁面上所有可用的人員名稱。 我試圖如何使用laravel中的goutte登錄Facebook

$crawler = $client->request('GET', 'https://www.facebook.com'); 
    $form = $crawler->selectButton('Log In')->form(); 

    $crawler = $client->submit($form, array('email' => 'fabpot', 'pass' => 'xxxxxx')); 
    // submit that form 
    $crawler = $client->submit($form); 
    echo $crawler->html(); 

    return $this->render('scraperBundle:Thing:index.html.twig'); 

但我得到的錯誤:

InvalidArgumentException in Crawler.php line 822: 
The current node list is empty. 

請幫助我。

回答

0

嘗試這是將工作

$client = new Client(); 
$crawler = $client->request('GET', 'https://en-gb.facebook.com/login/'); 
$form = $crawler->selectButton('Log In')->form(); 
$crawler = $client->submit($form, array('email' => 'email', 'pass' => 'pass')); 
$crawler->filter('.flash-error')->each(function ($node) { 
    print $node->text()."\n"; 
}); 
echo $crawler->html();