English 中文(简体)
网址浏览器
原标题:Facebook login to site bugs

When users come to my site they have the option to log in through facebook. If they are logged in to facebook, and hit the fb login button, it will show all the appropriate logged in dialog. However, if you log out of facebook (either through my site or through facebook itself) and then try to log in through my site again, it will bring you to facebook to sign in, then bring you back to my site. The url changes from x.net/index.php to x.net/index.php?state=... bunch of letters / numbers, but then doesn t return logged in dialog. Hit the button once again after that, and the page refreshes with a different (but similar) url, and returns all the logged in dialog.

任何关于如何解决这一问题的想法?

在这里,我使用的法典是连接手法,并获取标识和标志。

//facebook application
$fbconfig[ appid  ]     = "myAppId";
$fbconfig[ secret ]     = "myAppSecret";
$fbconfig[ baseurl ]    = "http://myNeatSite.net/index.php"; 


if (isset($_GET[ request_ids ])){
    //user comes from invitation
    //track them if you need
}

$user            =   null; //facebook user uid
try{
    include_once "facebook.php";
}
catch(Exception $o){
    error_log($o);
}
// Create our Application instance.
$facebook = new Facebook(array(
   appId   => $fbconfig[ appid ],
   secret  => $fbconfig[ secret ],
   cookie  => true,
));

//Facebook Authentication part
$user       = $facebook->getUser();


$loginUrl   = $facebook->getLoginUrl(
        array(
             scope          =>  email,publish_stream ,
             redirect_uri   => $fbconfig[ baseurl ]
        )
);

$logoutUrl  = $facebook->getLogoutUrl();


if ($user) {
  try {
    // Proceed knowing you have a logged in user who s authenticated.
    $user_profile = $facebook->api( /me );
  } catch (FacebookApiException $e) {
 $user = null;
  }
}
问题回答

As far as I see, you only process the case $user is not null (which means the user is already logged in), but ignore the other case.

if ($user) {
  try {
    // Proceed knowing you have a logged in user who s authenticated.
    $user_profile = $facebook->api( /me );
  } catch (FacebookApiException $e) {
 $user = null;
  }
}




相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Remotely authenticating client Windows user on demand

Suppose I am writing a server for a particular network protocol. If I know that the client is running on a Windows machine, is it possible for my server to authenticate the Windows user that owns the ...

Role/Permission based forms authorizing/authentication?

While looking into forms authorizing/authentication, I found that it is possible to do role based authorizing by adding an array of roles to a FormsAuthenticationTicket. That way I can write User....

热门标签