当我使用“getLoginUrl()”时,我得到一个无效的URL,其中包含error_description权限错误

时间:2013-07-30 06:15:52

标签: permissions facebook-php-sdk

我使用最新的PHP facebook SDK。但getUser()仍然返回0.我检查我的代码和我可以尝试的所有方法。我发现了这样的身份验证网址:

https://www.facebook.com/login.php?skip_api_login=1&api_key=XXXXXXXXXXXXX&signed_next=1&next=https%3A%2F%2Fwww.facebook.com%2Fdialog%2Foauth%3Fredirect_uri%3Dhttp%253A%252F%252FXXXXX.com%252FXXXXXX%252FXXXXXX%26state%3Dc1d7f9f1adb8f0807fc07e860f4a500f%26response_type%3Dtoken%26client_id%3D417867418281754%26ret%3Dlogin&cancel_uri=http%3A%2F%2FXXXXXXXXXXXX%2FXXXXXXXXXXXX%2FXXXXXXXXX%3Ferror%3Daccess_denied%26error_code%3D200%26error_description%3DPermissions%2Berror%26error_reason%3Duser_denied%26state%3Dc1d7f9f1adb8f0807fc07e860f4a500f%23_%3D_&display=page

我看到了一个错误。 [权限错误] [user_denied] 在应用身份验证时我点击了确定。

        session_start();

        $facebook = new Facebook(array(
                'appId'  => $client_id,
                'secret' => $client_ecret,
                'cookie' => true,
        ));

        $params = array(
                'scope' => 'email,publish_stream,publish_actions,read_stream',
                'redirect_uri' => $redirect_uri,
                );

        Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYPEER] = false;
        Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYHOST] = 2;

        $user = $facebook->getUser();

        if ($user) {
            try {

                // Proceed knowing you have a logged in user who's authenticated.
                $user_profile = $facebook->api('/me');

            } catch (FacebookApiException $e) {
                error_log($e);

                $user = null;
            }
        }

        if ($user) {
            $logoutUrl = $facebook->getLogoutUrl();
        } else {
            $loginUrl = $facebook->getLoginUrl($params);

            header('Location:' . $loginUrl);
        }

谁能帮帮我?

非常感谢。

0 个答案:

没有答案