facebook connect- $user_id = $facebook->getUser(); always returning 0 [duplicate]

断了今生、忘了曾经 提交于 2019-11-26 23:07:41

To get rid of this issue you need to do the following

Change

$login_url = $facebook->getLoginUrl(array(
    'scope'     => 'email,user_location,user_photos,publish_actions,basic_info', 
    'redirect_uri'  => 'http://localhost/dist/'
    ));

to

$login_url = $facebook->getLoginUrl(array(
    'scope'     => 'email,user_location,user_photos,publish_actions,basic_info', 
    'redirect_uri'  => 'http://localhost/dist/index.php'
    ));

Leave domain name blank in the following setting. Dont give localhost.com

App Domains : localhost.com

Then

Valid OAuth redirect URIs :http://localhost/dist/

to

Valid OAuth redirect URIs :`http://localhost/dist/index.php

Now try there after.

change your app secret from app configuration page.then use this new app secret in above page you have mentioned.Delete all the cookies in browser and try loading the page you will get the correct response.

to me it sounds issue of local host if you can use a domain to test your code i have a one page login system running on my website i can send you all code how ever you code is looking good.

Edit base_facebook.php library and replace existing getCode() function with

protected function getCode() {
$server_info = array_merge($_GET, $_POST, $_COOKIE);
    if (isset($server_info['code'])) {
        if ($this->state !== null && isset($server_info['state']) && $this->state === $server_info['state']) {
            $this->state = null;
            $this->clearPersistentData('state');
            return $server_info['code'];
        } else {
            self::errorLog('CSRF state token does not match one provided.');
            return false;
        }
    }
    return false;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!