CakePHP / Facebook 插件 - 注销按钮链接到 #
我正在尝试将 Facebook 插件与 CakePHP 一起使用 - 一切看起来都很顺利 - 我可以使用喜欢/推荐按钮 - 我可以通过 facebook 登录 - 它会要求我告诉它的事情的许可...
等等问题是,我的注销按钮只是链接到您所在的任何页面加上 #
所以 - 如果我在index.php,注销按钮链接到index.php#
我包括正确的 facebook html 标签和 init()在正确的位置。
有什么想法吗?
这是我的注销按钮代码:
if(!$session->check('Auth.User.id') && !$this->Connect->user('id')) {
echo $this->Html->link('LOGIN', array('controller' => 'users', 'action' => 'login'));
} else {
echo $facebook->logout(array('redirect' => array('controller'=>'users', 'action'=>'logout'), 'label' => 'LOGOUT'));
}
编辑
需要明确的是 - 我不在乎链接是否是 #,但注销按钮除了将浏览器推到顶部之外什么也不做。它不会注销,也不会刷新页面。
EDIT2
如果我启动一个新的浏览器,登录 Facebook,然后访问我的网站,它会自动登录 - 此时,注销按钮就可以正常工作了。但是 - 如果我通过网站上的用户登录(而不是 FB)登录,注销按钮只会将我弹出到页面顶部(即 - 空锚链接)
I'm attempting to use the Facebook plugin with CakePHP - all seems like it's going well - I can use the like/recommend buttons - I can login via facebook - it asks for permission for things that I told it to...etc
The problem is, my LOGOUT button just links to whatever page you're on plus a #
So - if I'm on index.php, the logout button links to index.php#
I AM including the correct facebook html tag and init() in the correct locations.
Any thoughts?
Here is my code for the logout button:
if(!$session->check('Auth.User.id') && !$this->Connect->user('id')) {
echo $this->Html->link('LOGIN', array('controller' => 'users', 'action' => 'login'));
} else {
echo $facebook->logout(array('redirect' => array('controller'=>'users', 'action'=>'logout'), 'label' => 'LOGOUT'));
}
EDIT
And to be clear - I wouldn't care if the link is a #, but the logout button does nothing at all except bump the browser up to the top. It doesn't log out, it doesn't refresh the page.
EDIT2
If I start a fresh browser, login into Facebook, then go to my site, it auto-logs me in - at that point, the logout button works perfectly. But - if I log-in via a user-login on my site (instead of FB), the logout button just pops me to the top of the page (ie - the empty anchor link)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我目前正在怀疑同样的问题(加上另外 1 个),我发现 FacebookHelper.php 似乎错误地处理 $options:
我不是 PHP 专家,并且可能是错误的,但似乎如果$options 已填充,例如重定向,但没有 img 参数,则屏幕上不会出现任何按钮(它会转到“此处”)。通过更改上面的代码,我可以显示面子书链接并且 FB 注销可以工作。现在我正在调试一个身份验证问题,其中会话在注销后不断重新生成(没有 FB 连接)。
我的“固定代码”仍然是 WIP 并且丑陋的是:
`
I am currently dubugging the same problem (plus 1 other), and what I have found is that the FacebookHelper.php seems to handle $options incorrectly:
I'm not very expert in PHP, and could be wrong, but it seems that if $options are populated e.g. redirect, but no img param, then no button appears on screen (it goes to 'HERE'). By changing the code above, I can get then face book link displayed and the FB logout works. Now I' debugging an Auth prob where sessions keep regenerating after logout (with no FB connection).
My 'fixed code', still WIP and ugly is:
`
该链接应生成为“#”。注销函数通过 JavaScript onclick 事件生成此链接,该事件调用 FB 并注销用户。我会检查你是否遇到了 javascript 错误。您参考源代码进行确认 。
The link should be generated as a "#". The logout function generates this link with a javascript onclick event, which makes the call to FB and logs the user out. I would check if you're getting javascript errors. You reference the source code for confirmation.