当我尝试使用Fb登录第一次登录时我得到错误,并且当我尝试登录时成功登录2秒

时间:2015-04-10 11:40:04

标签: facebook cakephp facebook-login

当我第一次尝试登录时,我收到异常的错误消息:\

  

[message] =>必须使用活动访问令牌来查询有关当前用户的信息。

以下是我的代码:

Configure::load('facebook');
$appId      = Configure::read('Facebook.appId');
$app_secret = Configure::read('Facebook.secret');
$facebook   = new Facebook(array(
    'appId' => $appId, // fb app id (mentioned in facebook.php)
    'secret' => $app_secret, // fb secret key
    'cookie' => true,
    'oauth ' => true
));

//======================================
// to get loggedin user details
//======================================

$user = $facebook->getUser();

//$access_token = $facebook->getAccessToken();
if (!empty($user)) {
    try {
        $user_profile = $facebook->api('/me');
    } catch catch (FacebookApiException $e) {
        pr($e);
    }
}

// =========================== //查看

function facebookLogin(detectedTimeZone){

    window.open('https://www.facebook.com/dialog/oauth?client_id=<?php echo $appId; ?>&display=popup&redirect_uri='+base_url+'/users/facebook_login/scope=email','','width=600, height=400');
       }

       <div style="float:left;"><a onclick="facebookLogin(detectedTimeZone);" href="javascript: void(0);" id="fb-auth"><img src="/images/fblogin.png"></a>
                        </div>

0 个答案:

没有答案