dongsu1951 2012-05-29 12:21 采纳率: 0%
浏览 50

如何从Facebook退出

I used that code to connect to facebook

// Get User ID
$user = $facebook->getUser();
if ($user) {
  try {
    // Proceed knowing you have a logged in user who's authenticated.
    $user_profile = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
  }
}
ob_clean();
// Login or logout url will be needed depending on current user state.
if ($user) {
  $logoutUrl = $facebook->getLogoutUrl();
} else {
  $loginUrl = $facebook->getLoginUrl();
}

then logOut form facebook

if ($user): ?>
      <a href="<?php echo $logoutUrl; ?>">Logout</a>
    <?php else: ?>
       <a href="<?php echo $loginUrl; ?>">Login with Facebook</a>
<?php endif;

if the user clicks the link, then logOut. but I want just running pace code. not link. in the page, ı will work where ı wrote.

I did like that but didn't work

header('Location: '.$logoutUrl );

To sum up: in my page I want to LOGOUT not only in my cookies but also on facebook.

like that:

if(!isset($_COOKIE["kullanici"]))
{
  echo "Giriþ yapmamýþsýnýz  Bu sayfaya giriþ izniniz yoktur...";
  exit();
}
else
{ 
   setcookie("kullanici_mail", "", time()-3600,"/");
  if($user)
  //  here FACBOOK LOGOUT CODE SHOULD BE
  // AND THAN GO 
  ?>
   <script language="JavaScript">
   <!-- Sakla
   parent.location.href="../index.php";
   // -->
   </script>
 <?
}
  • 写回答

2条回答 默认 最新

  • dongqian1893 2012-05-29 12:36
    关注

    I don't quite understand what you want to accomplish here, but you might want to try the destroy session function that comes with the facebook php SDK. Its not documented on the site but it is in there and I think it might be what you need.

    $facebook->destroySession;

    评论

报告相同问题?

悬赏问题

  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退
  • ¥20 win系统的PYQT程序生成的数据如何放入云服务器阿里云window版?
  • ¥50 invest生境质量模块