PHP SDK - Facebook注销 [英] PHP SDK - Facebook Logout
问题描述
我想知道,使用<$ c $中提供的功能注销时c> base_facebook.php 从sdk,如果有办法阻止它从实际注销的Facebook,但仍然删除网站应用程序的会话?
以下是来自 base_facebook.php的注销功能
/ **
*获取适用于重定向的注销URL。
*
*参数:
* - next:成功注销后要访问的url
*
* @param数组$ params提供自定义参数
* @return string注销流的URL
* /
public function getLogoutUrl($ params = array()){
session_destroy();
return $ this-> getUrl(
'www',
'logout.php',
array_merge(array(
'next'=> $ this - > getCurrentUrl(),
'access_token'=> $ this-> getUserAccessToken(),
),$ params)
);
}
然后我的注销URL是:$ code $ $ logoutUrl = $ facebook-> getLogoutUrl(); 然后显然使用锚标签注销:< a href =<?php echo $ logoutUrl;?>> ;注销< / a>
谢谢。
不要使用$ logoutUrl。
< li>< a href =?action = logout>注销< / a>< / li> ;
在你的PHP代码中添加这个。这只会从您的应用程序中注销。
if(isset($ _ GET ['action'])&& $ _GET ['action'] ==='logout'){
$ facebook-> destroySession();
}
I am using the latest version of PHP SDK for Facebook (3.2.1)
I was wondering, when logging out using the function provided in base_facebook.php
from the sdk, if there was a way to stop it from actually logging out of facebook, but still deleting the session for the website application?
Below is the logout function from base_facebook.php
/**
* Get a Logout URL suitable for use with redirects.
*
* The parameters:
* - next: the url to go to after a successful logout
*
* @param array $params Provide custom parameters
* @return string The URL for the logout flow
*/
public function getLogoutUrl($params=array()) {
session_destroy();
return $this->getUrl(
'www',
'logout.php',
array_merge(array(
'next' => $this->getCurrentUrl(),
'access_token' => $this->getUserAccessToken(),
), $params)
);
}
and then my logout url is: $logoutUrl = $facebook->getLogoutUrl();
then obviously using a anchor tag to logout: <a href="<?php echo $logoutUrl; ?>">Logout</a>
Thank you.
Dont use $logoutUrl.
<li><a href="?action=logout">Logout</a></li>
And in your php code add this. This will only logout you from your app .
if(isset($_GET['action']) && $_GET['action'] === 'logout'){
$facebook->destroySession();
}
这篇关于PHP SDK - Facebook注销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!