0

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

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%252FXXXXXX.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] 应用认证时我点击ok。

        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);
        }

谁能帮我?

非常感谢。

4

0 回答 0