我不能让Facebook的PHP-SDK 3.x的注册/登录用户的整合工作(I cant make

2019-10-16 14:59发布

我按照这个教程来整合Facebook的: http://25labs.com/tutorial-integrate-facebook-connect-to-your-website-using-php-sdk-v-3-xx-which-uses-graph-api/

我的脚本

        $app_id     = "xxxx";
        $app_secret = "xxxxxxx";
        $site_url   = "http://site.com/auth/facebook";

        include_once "src/facebook.php";

        $facebook = new Facebook(array(
            'appId'     => $app_id,
            'secret'    => $app_secret,
            ));

         $user = $facebook->getUser();

        if($user){
            // Get logout URL
            $logoutUrl = $facebook->getLogoutUrl(array(
                'next'  => 'http://site.com/enter',
 // URL to which to redirect the user after logging out
                ));
        }else{
            // Get login URL
            $loginUrl = $facebook->getLoginUrl(array(
                'scope'     => 'user_about_me,user_hometown,email,offline_access',
 // Permissions to request from the user
                'redirect_uri'  => 'http://site.com',
 // URL to redirect the user to once the login/authorization process is complete.
                ));

    echo '<a href="'.$loginUrl.'">login</a>';
    }

由于我无法登录我看到的登录链接,现在当我点击它重定向我的页面,我的选择,但是当我回去使用的print_r($ USER_INFO); 我没有得到任何东西,再看看我的登录链接..所以我做错了

这是我点击进入链接后,得到

http://site.net/home?state=a074b46878d90ff3ebf5c02049c077e6&code=AQDCOhwA9h1qGOHntZCxBbeUUBmA3zXzjhum8zhTqWfE_6V17F-MpD91anIEgGNGV7eLge8H61nz53S6SlkzZ70Zcbi_uJKeD9uMFiaIrobaYS-dapz-m2pKlPk9kGVDaxUf80C7nIyh3-lUzgCNY2H6Cw4Zh2UoB0raRnyrDngSSn7H9z6mCTRRW-CbcH_bpKs# =

文章来源: I cant make the Facebook PHP-SDK 3.x register/login user integration to work