I read lots of questions which are related to my problem. However, I can't resolve it. The getUser() from Facebook-php-sdk always return 0 though I logged in. From my log:
Invalid or no certificate authority found, using bundled information
I added "CURLOPT_SSL_VERIFYPEER => FALSE" to BaseFacebook::$CURL_OPTS. However, it's not working.
My code:
<?php
try {
$facebook = new Social\Facebook ();
$user_fb_id = $facebook->getUser();
if ($user_fb_id) {
//do something
} else {
$params = array(
'scope' => 'email, user_activities, read_stream, publish_stream, user_birthday, user_likes',
//'display' => 'touch',
'redirect_uri' => Uri::base(false) . 'userjob/login?url=' . $url
);
$login_url = $facebook->getLoginUrl($params);
Response::redirect($login_url);
}
}
catch (Exception $e) {
echo "Error";
echo $e->getMessage();
die();
}
By the way, I use PHP5.3.2 (MAMP 1.9, MAC OS 10.7.5), the above code working fine on the other computers and working on the localhost to connect with Facebook. However, It's failed on my computer.
Update: (Solved)
Thank you all for helping me! The problem is my hosts file. I clear some old IPs which are related to Facebook and it's working!