我想使用php
的curl自动将评论添加到Facebook。该代码在localhost(xampp)
中工作正常,但在godaddy host
中工作正常。Curl无法登录Facebook。
我尝试了所有操作,将session
更改为false
,CURLOPT_SSL_VERIFYPEER
false
CURLOPT_SSL_VERIFYhost
false
...无济于事。
<?php
$login_email = '';
$login_pass = '';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://wwww.facebook.com/login.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_COOKIEJAR, "cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
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_setopt($ch, CURLOPT_ENCODING, 'UTF-8');
curl_exec($ch);
curl_setopt($ch, CURLOPT_URL,"https://mbasic.facebook.com/180562885329138"); $page =
curl_exec($ch) or die(curl_error($ch));
echo htmlspecialchars_decode($page); ?>
我搜索了很多,我认为这是服务器问题。
实际结果:返回主页而不登录。