gpt4 book ai didi

Facebook FB.ui 注销不会触发

转载 作者:行者123 更新时间:2023-12-02 22:12:24 24 4
gpt4 key购买 nike

FB.ui(
{
method: 'feed',
name: 'some text',
link: 'some text',
picture: 'aa.jpg',
caption: 'some text',
description: 'some text',
message: 'some text'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
});
}

该代码工作正常,现在我喜欢之后:

alert('Post was published.');

静默地从 Facebook 注销怎么办?

添加该代码 alert('postpublish') 后没有执行任何操作!

FB.ui(
{ method:'auth.logout', display:'hidden' },
function() { alert("you're logged out!"); }
);

我发现:FB auth.logout is being raised after being logged in using the "server-side-workflow" (OAuth 2.0)但不确定我是否足够理解代码以知道它执行我的要求!

最佳答案

  1. https://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/

  2. https://developers.facebook.com/docs/reference/javascript/FB.logout/

Best Practices

FB.logout will log the user out of both your site and Facebook. You will need to have a valid access token for the user in order to call the function.

Calling FB.logout will also invalidate the access token that you have for the user, unless you have the offline_access permission.

我使用评论框编写了一个示例来触发自动注销 http://shawnsspace.com/fb.logout.test.php

代码:

<小时/>
    <div id="fb-root"></div>    
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '112104298812138',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
//channelUrl : 'http://WWW.MYDOMAIN.COM/channel.html', // channel.html file
oauth : true // enable OAuth 2.0
});
FB.Canvas.EarlyFlush.addResource("http://shawnsspace.com/index.php");
FB.Canvas.setAutoResize();
FB.getLoginStatus(function(response) {
if (response.authResponse) {

var accessToken = response.authResponse.accessToken;
} else {
}
});
FB.Event.subscribe('comment.create', function(response) {
//alert(JSON.stringify(response));
FB.logout(function(response) {
window.location.reload();
});
});
FB.Event.subscribe('auth.login', function(response) {
//top.location.href = 'http://apps.facebook.com/shawnsspace/fbcomments.php?ref=loggedin';
window.location.reload();
});
FB.Event.subscribe('auth.logout', function(response) {
//top.location.href = "http://apps.facebook.com/shawnsspace/fbcomments.php?ref=loggedout";
alert('logged out');
});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>

关于Facebook FB.ui 注销不会触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7774002/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com