Facebook php SDK getLogoutUrl()问题 [英] Facebook php SDK getLogoutUrl() problem
问题描述
$ logoutUrl = $ facebook-> getLogoutUrl(array ('next'=>'logout.php'));
和 $ logoutUrl
显示正确的链接,它不是将我重定向到下一个指定的URL。它将我重定向到开始注销的页面。
因为它看起来有很多文章在互联网上,但他们都使用相同的方法,对于许多人,工作
如何从Facebook上正确注销用户,然后执行我的常规注销脚本?
编辑: -javascriptSDK的注销。
< a id =logouthref =logout.phponclick =FB.logout (function(response){window.location ='logout.php'}); return false; title =<?php echo $ lang ['logout'];?>><?php echo $ lang ['logout']; ?>< / A>
你应该使用绝对URL。例如
//(或https://)
$ here ='http://' $ _SERVER ['HTTP_HOST']。 $ _SERVER [ REQUEST_URI];
$ next = preg_replace('〜#。* $〜s','',$ here);
$ next = preg_replace('〜\?。* $〜s','',$ next);
$ next = preg_replace('〜/ [^ /] * $〜s','/logout.php',$ next);
$ logoutUrl = $ facebook-> getLogoutUrl(array('next'=> $ next));
或简单地:
$ logoutUrl = $ facebook-> getLogoutUrl(array('next'=>'http://...../logout.php'));
When i want to logout users from my website i use:
$logoutUrl = $facebook->getLogoutUrl(array('next' => 'logout.php'));
And $logoutUrl
displays correct link, however it's not redirecting me to the url specified in next. It redirects me to the page that started logout.
As it looks that there is very much articles on internet, but they all use same methods and for many people those don't work. How to properly logout user from facebook and then perform my regular logout script?
EDIT: This worked but still want some non-javascriptSDK based logout.
<a id="logout" href="logout.php" onclick="FB.logout(function(response) { window.location = 'logout.php' }); return false;" title="<?php echo $lang['logout']; ?>"><?php echo $lang['logout']; ?></a>
You should use absolute URLs. e.g.
// (or https://)
$here = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$next = preg_replace('~#.*$~s', '', $here);
$next = preg_replace('~\?.*$~s', '', $next);
$next = preg_replace('~/[^/]*$~s', '/logout.php', $next);
$logoutUrl = $facebook->getLogoutUrl(array('next' => $next));
Or simply:
$logoutUrl = $facebook->getLogoutUrl(array('next' => 'http://...../logout.php'));
这篇关于Facebook php SDK getLogoutUrl()问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!