我有以下代码(我facebook.php
正确地加了进来,appId
和appSecret
也是正确的):Facebook的注销与PHP和JS SDK
<?php
define('APP_ID', 'XXX');
$facebook = new Facebook(array(
'appId' => APP_ID,
'secret' => 'XXX',
));
$userId = $facebook->getUser();
?>
<html>
<body>
<div id="fb-root"></div>
<?php if ($userId) {
$userInfo = $facebook->api('/' + $userId); ?>
Welcome <?= $userInfo['email'] ?> <fb:logout-button></fb:logout-button>
<?php } else { ?>
<div id="fb-root"></div>
<fb:login-button></fb:login-button>
<?php } ?>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '<?= APP_ID ?>',
status : true,
cookie : true,
xfbml : true,
oauth : true,
});
FB.logout(function()
{
top.location.href = 'http://www.google.com'
});
};
(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));
</script>
我的代码总是输出WELCOM [email protected]
。如何正确注销以便我可以测试它以再次登录?
@chris:这对你有帮助吗?我问,因为没有评论。 – 2012-02-08 06:57:28