Whenever I try to login a prompt opens asking for the basic permissions, after that its being redirected to my redirect_uri with an URL
=\">http://loc
It might be Worked using
$opts[CURLOPT_SSL_VERIFYPEER] = false; after $opts = self::$CURL_OPTS; on file base_facebook.php.
if someone is still banging their head over this here is what is wrong now. I was hired to fix this mess!
Check App domain in fb panel , must match with the domain where your app is.
edit base_facebook.php find:
public function getAccessToken() {
if ($this->accessToken !== null) {
// we've done this already and cached it. Just return.
return $this->accessToken;
}
// first establish access token to be the application
// access token, in case we navigate to the /oauth/access_token
// endpoint, where SOME access token is required.
$getApplicationAccessToken = $this->getApplicationAccessToken();
$this->setAccessToken($getApplicationAccessToken);
$user_access_token = $this->getUserAccessToken();
if ($user_access_token) {
$this->setAccessToken($user_access_token);
}
return $this->accessToken;
}
to::
public function getAccessToken() {
if ($this->accessToken !== null) {
// we've done this already and cached it. Just return.
return $this->accessToken;
}
// first establish access token to be the application
// access token, in case we navigate to the /oauth/access_token
// endpoint, where SOME access token is required.
$getApplicationAccessToken = $this->getApplicationAccessToken();
$this->setAccessToken($getApplicationAccessToken);
$user_access_token = $this->getUserAccessToken();
if ($user_access_token) {
//$this->setAccessToken($user_access_token);
$this->accessToken = $user_access_token; //edit; msolution
}
return $this->accessToken;
}
find the line:
parse_str($access_token_response, $response_params);
replace it with:
//parse_str($access_token_response, $response_params); //edit:: msolution;;
$response_params = json_decode($access_token_response, true );
commenting the original and adding json_decode
thats it!
If User is logged in and still getting $user = 0 I faced this issue on different occasions but SDK issue is not happening to everyone. So I'm not sure what goes wrong here. But I dig in to it little bit and found solution as mentioned below.
SOLUTION : This worked for me after trying for many solutions for this issue.
In base_facebook.php file, find the makeRequest() method and check for following Line.
$opts = self::$CURL_OPTS;
Immediately following it, add this line
$opts[CURLOPT_SSL_VERIFYPEER] = false;
More details can be found here - http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/
After several hours, the solution for me was (Let's say my site is http://www.site123.com):
Settings @ https://developers.facebook.com
PHP Code - fb_config.php
//Declarations
$app_id = "{you AppID}";
$app_secret = "{your App Secret}";
$site_url = "http://site123.com/receive_data_from_facebook.php";
//New Facebook
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => TRUE, /* Optional */
'oath' => TRUE /* Optional */
));
//Login URL
$loginUrl = $facebook->getLoginUrl(array(
'scope' => 'email,user_birthday',
'redirect_uri' => $site_url,
));
//Get FacebookUserID
$fbuser = $facebook->getUser();
Important Note Also: I had some issues with Firefox $facebook->getUser() was 0 even my code was working on Chrome. But after cleaning Firefox cache, it worked nicely!
Hope it helps.
Change this
$loginUrl = $facebook->getLoginUrl(array (
'display' => 'popup',
'redirect_uri' => 'http://localhost/demo'
));
to
$loginUrl = $facebook->getLoginUrl(array (
'display' => 'popup',
'redirect_uri' => 'http://localhost/demo/index.php'
));
And see if this works !!