2011-02-25 77 views
2

我的网页是动态构建的。我有page1.php,page2.php等,但它们被称为类似于:index.php?page = page1Facebook:更改登出网址

当我点击注销按钮它重新加载page1.php而不是index.php?页面= page1

如何更改正确重新加载的代码,我需要编辑什么?

下面是我使用的代码:

我有这样的注销按钮:

<a href="<?php echo $logoutUrl; ?>"><img border=0 src="http://static.ak.fbcdn.net/rsrc.php/z2Y31/hash/cxrz4k7j.gif"></a> 

其中:

$logoutUrl = $facebook->getLogoutUrl(); 

我包括facebook.php和这里的getLogoutUrl();:

public function getLogoutUrl($params=array()) { 
    return $this->getUrl(
     'www', 
     'logout.php', 
     array_merge(array(
     'next'   => $this->getCurrentUrl(), 
     'access_token' => $this->getAccessToken(), 
    ), $params) 
    ); 
    } 

和getCurrentUrl():

protected function getCurrentUrl() { 
    $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' 
     ? 'https://' 
     : 'http://'; 
    $currentUrl = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; 
    $parts = parse_url($currentUrl); 

    // drop known fb params 
    $query = ''; 
    if (!empty($parts['query'])) { 
     $params = array(); 
     parse_str($parts['query'], $params); 
     foreach(self::$DROP_QUERY_PARAMS as $key) { 
     unset($params[$key]); 
     } 
     if (!empty($params)) { 
     $query = '?' . http_build_query($params, null, '&'); 
     } 
    } 

    // use port if non default 
    $port = 
     isset($parts['port']) && 
     (($protocol === 'http://' && $parts['port'] !== 80) || 
     ($protocol === 'https://' && $parts['port'] !== 443)) 
     ? ':' . $parts['port'] : ''; 

    // rebuild 
    return $protocol . $parts['host'] . $port . $parts['path'] . $query; 
    } 

非常感谢!

回答

2

当调用

 
$logoutUrl = $facebook->getLogoutUrl(); 

你可以告诉他你在哪里希望他一旦他LOGES了回报用户:

 
$logoutUrl = $facebook->getLogoutUrl(
    array(
     'next' => 'http://mydomain.com/index.php?page=page1' 
    ) 
); 
+0

由于一吨,你救救我吧! – user523129 2011-02-25 13:55:56

+0

这似乎不再适用。 :/ – James 2013-01-23 02:00:18