Facebook API注销我的应用程序,但不是Facebook [英] Facebook API Logout of my app but not facebook

查看:195
本文介绍了Facebook API注销我的应用程序,但不是Facebook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Facebook登录我的应用程序(一个网站),但让我登录到Facebook.com?



这会记录我好的:

  window.fbAsyncInit = function()
{
FB.init({
appId:'<?= APP_ID?>',
status:true,
cookie:true,
xfbml:true,
oauth:true,
});

FB.Event.subscribe('auth.login',function(response)
{alert(response);
window.location ='http://reviewsie.com / accounts / facebook';
});

};

(function(d)
{
var js,id ='facebook-jssdk'; if(d.getElementById(id)){return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src =//connect.facebook.net/en_US/all.js;
d.getElementsByTagName('head')[0] .appendChild(js);
}(document));

但是,我点击我的网站上的注销,我把我的会话杀死到我的应用程序。然后当您再次单击fb:登录按钮时,它只是打开和关闭,不会执行任何操作,因为我仍然连接到Facebook。我想要它重定向。



但是,如果我注销我也使用Facebook :: logoutUrl它将我从我的应用程序和Facebook,这不是我想要的。 / p>

解决方案

您确定要只注销您的应用,而不是fb,如果您使用fb登录?什么样的应用可能想做这样的事情?为什么?这样做有什么好处?






但是,如果你真的想(hack),在index.php: p>

 <?php 
require'init.php'; // general init
require'init_fb.php'; //设置$ fb_id,如果登录到fb

if(isset($ fb_id)and!isset($ _ SESSION ['do_not_auto_login'])){
echo< a href = '/注销' >退出< /按钮>中;
include'app.php';
返回;
}

if(isset($ _ SESSION ['do_not_auto_login'])
echo< a href ='/ re_login'> FB登录< / button>;
else包含'html_and_js_fb_login_code_and_button.php';

包含'startpage.php';
?>

和logout.php:

  $ _ SESSION ['do_not_auto_login'] = true; 
// destroy-code

和re_login.php:

  unset($ _ SESSION ['do_not_auto_login']); 
header(location:/); // re-direct回到index.php

不完美,但有些好,希望你得到黑客! p>




但是,为什么?如果你不觉得你的用户想回来,问如何删除我的fb应用程序从用户?或某事,或尝试@ DMCS的答案..为什么?


How do I make a logout using Facebook's api log me out of my app (a website), but keep me logged into facebook.com?

This logs me in alright:

 window.fbAsyncInit = function()
{
        FB.init({
            appId      : '<?= APP_ID ?>',
            status     : true, 
            cookie     : true,
            xfbml      : true,
            oauth      : true,
        });

    FB.Event.subscribe('auth.login', function(response)
    {alert(response);
            window.location = 'http://reviewsie.com/accounts/facebook';
        });

    };

  (function(d)
{
        var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
        js = d.createElement('script'); js.id = id; js.async = true;
        js.src = "//connect.facebook.net/en_US/all.js";
        d.getElementsByTagName('head')[0].appendChild(js);
    }(document));

But then I click logout on my site which I kill my session to my app. Then when you click on the fb:login-button again, it just opens and closes and doesn't do anything because I'm still connected to facebook. I want it to redirect.

But if when I logout I also use Facebook::logoutUrl it logs me out of my app AND facebook which is not what I want.

解决方案

Are you sure you want to only logout of your app, and not fb too, if you logged in using fb? What kind of app could want to do something like that? And why? What's the benefit of doing so?


But if you really want to (hack), in index.php:

<?php
require 'init.php';    // general init
require 'init_fb.php'; // sets $fb_id if logged in to fb

if (isset($fb_id) and !isset($_SESSION['do_not_auto_login'])) {
    echo "<a href='/logout'>Logout</button>";
    include 'app.php';
    return;
}

if (isset($_SESSION['do_not_auto_login'])
     echo "<a href='/re_login'>FB Login</button>";
else include 'html_and_js_fb_login_code_and_button.php';

include 'startpage.php';
?>

and in logout.php:

$_SESSION['do_not_auto_login'] = true;
// destroy-code

and in re_login.php:

unset($_SESSION['do_not_auto_login']);
header("location: /"); // re-direct back to index.php

Not perfect, but works somewhat good. Hope you get the hack!


But still, why?? If you don't think your user would like to come back, ask "How to remove my fb-app from user?" or something instead or try @DMCS's answer.. Why?

这篇关于Facebook API注销我的应用程序,但不是Facebook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆