2014-11-02 212 views
0

我在一个网站上工作,并使用steam openid,至今没有问题。 问题是,当我试图将用户重定向到蒸汽开放页面时,它不起作用,并将它们重定向到steamcommunity.com的根目录。

下面是代码:

if (!isset($_SESSION['steamid']) && $_GET['a'] == "login") { 
    $url = SteamSignIn::genUrl($_AMCFG['login_dir']); 
    print($url); 
    header("Location: ".$url); 
} 

手动输入,但重定向正如我所说的,不是那么好当生成的URL完美的作品。 我试图手动替换标头中的$ url,它工作正常。

header('Location: https://steamcommunity.com/openid/login?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=checkid_setup&openid.return_to=http%3A%2F%2Flocalhost%2Fadminmailer%2Findex.php&openid.realm=http%3A%2F%2Flocalhost&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select'); 

我很困惑,为什么这不按预期工作。

作为一个临时的解决办法我已经加入这个头:

<?php 
    if (isset($_GET['a'])) { 
     if (!isset($_SESSION['steamid']) && $_GET['a'] == "login") { 
      $url = SteamSignIn::genUrl($_AMCFG['login_dir']); 
      ?><meta http-equiv="refresh" content="0; url=<?php print($url); ?>" /><?php 
     } 
    } 
?> 
+0

那么,什么是“不那么好”呢?怎么了?你有没有检查过它不是Steam最终重定向你? – ceejayoz 2014-11-02 13:56:53

+1

你不应该在更改标题前打印 – 2014-11-02 13:57:49

+0

正如我所说的,它将我重定向到没有/ openid的steamcommunity.com的根目录... – Starfox64 2014-11-02 13:58:31

回答

3

header重定向不打印任何东西。 Read Doc

这可能是重定向正在以正确的地方做,但之后再次被重定向到主页即https://steamcommunity.com

+0

打印出于调试目的,即使没有它,我仍然有同样的问题。为什么会蒸汽重定向我,如果当我使用生成的网址,它工作正常,它必须是标题不正确解释的网址是奇怪的,因为当我手动添加它工作正常。 – Starfox64 2014-11-02 14:02:22