登录Facebook Curl PHP

时间:2017-01-22 12:16:20

标签: php facebook curl

我想使用网址登录Facebook并将curl标头IP更改为$_SERVER['REMOTE_ADDR']。但IP不变,请告诉我如何解决这个问题。

  $ipku = $_SERVER['REMOTE_ADDR'];
  $ip = array("REMOTE_ADDR: $ipku", "HTTP_X_FORWARDED_FOR: $ipku");

$ch = curl_init();
 curl_setopt($ch, CURLOPT_URL, 'https://m.facebook.com/login.php');

 curl_setopt($ch, CURLOPT_POSTFIELDS,'email='.urlencode($em).'&pass='.urlencode($pa).'&login=Login');

 curl_setopt($ch, CURLOPT_POST, 1);

 curl_setopt($ch, CURLOPT_HEADER, 0);

 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

 curl_setopt($chs,CURLOPT_HTTPHEADER,$ip);

 curl_setopt($ch, CURLOPT_COOKIEJAR,$cookie);

 curl_setopt($ch, CURLOPT_COOKIEFILE,$cookie);

 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

 curl_setopt($ch, CURLOPT_USERAGENT,'Opera/9.80 (Series 60; Opera Mini/6.5.27309/34.1445; U; en) Presto/2.8.119 Version/11.10');

 curl_setopt($ch, CURLOPT_REFERER,
   "https://www.facebook.com");

    $body = curl_exec($ch);

1 个答案:

答案 0 :(得分:0)

尝试添加此内容:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);

而且,你在#15行中输错了,所以做出这样的改变:

// curl_setopt($chs,CURLOPT_HTTPHEADER,$ip);
curl_setopt($ch, CURLOPT_HTTPHEADER, $ip);