dongshi1188 2014-01-24 10:05
浏览 104

通过Steam无法正常工作(OpenID)

Alright, I am having a bit of a problem with signing in through steam on my website. The code seems to work up until you press the "Yes, sign in." here: Screenshot.

When I click the "Yes, sign in." button it redirects me back to the page that the sign in button was on and the sign in button is not not visible as if it worked but the scripted logout button is not there either. It is just a blank page and it has a really long URL:

http://localhost/Websites/Unknown%20Infernos/?page=login&login&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=id_res&openid.op_endpoint=https%3A%2F%2Fsteamcommunity.com%2Fopenid%2Flogin&openid.claimed_id=http%3A%2F%2Fsteamcommunity.com%2Fopenid%2Fid%2F76561198059756738&openid.identity=http%3A%2F%2Fsteamcommunity.com%2Fopenid%2Fid%2F76561198059756738&openid.return_to=http%3A%2F%2Flocalhost%2FWebsites%2FUnknown%2520Infernos%2F%3Fpage%3Dlogin%26login&openid.response_nonce=2014-01-24T10%3A00%3A27Ze43wSImRFeCb5vc9qw8uwlv8y9c%3D&openid.assoc_handle=1234567890&openid.signed=signed%2Cop_endpoint%2Cclaimed_id%2Cidentity%2Creturn_to%2Cresponse_nonce%2Cassoc_handle&openid.sig=SYWQBh%2BxowKdUqWvVhK6nl7Vskk%3D

The log in button also comes back after a page refresh.

Here is the code, I am using the LightOpenID API.

<?php
session_start();

include "openid.php";

$key = "XXXXXXXXXXXXXXXXXXXXXXXXX";
$OpenID = new LightOpenID("localhost");

if (!$OpenID->mode) {

    if (isset($_GET['login'])) {
        $OpenID->identity = "http://steamcommunity.com/openid";
        header("Location: {$OpenID->authUrl()}");
    }

    if (!isset($_SESSION['T2SteamAuth'])) {
        $login = "<div id=\"login\">Welcome Guest. Please <a href=\"?login\"><img src=\"http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_small.png\"/></a> to access this website.</div>";
    } elseif ($OpenID->mode == "cancel") {
        echo "user has cancelled Authentication.";
    } else {

        if (!isset($_SESSION['T2SteamAuth'])) {

            $_SESSION['T2SteamAuth'] = $OpenID->validate() ? $OpenID->identity : null;
            $_SESSION['T2SteamID64'] = str_replace("http://steamcommunity.com/openid/id", "", $_SESSION['T2SteamAuth']);

            if ($_SESSION['T2SteamAuth'] !== null) {

                $Steam64 = str_replace("http://steamcommunity.com/openid/id", "", $_SESSION['T2SteamAuth']);
                $profile = file_get_contents("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key={$key}&steamids={$Steam64}");
                $buffer = fopen("cache/{$Steam64}.json", "w+");
                fwrite($buffer, $profile);
                fclose($buffer);

            }

            header("Location: ./index.php")

        }

    }

    if (isset($_SESSION['T2SteamAuth'])) {

        $login = "<div id=\"login\">Welcome Guest. Please <a href=\"?logout\">Logout</a> to access this website.</div>";

    }

    if (isset($_GET['logout'])) {

        unset($_SESSION['T2SteamAuth']);
        unset($_SESSION['T2SteamID64']);
        header("Location: ./index.php");

    }

    $steam = json_decode(file_get_contents("cache/{$_SESSION['T2SteamID64']}.json"));

    echo $login;

    //echo "<img src\"{$steam->responce->players[0]->avatarfull}\"/>";

}

?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
    • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
    • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
    • ¥20 腾讯企业邮箱邮件可以恢复么
    • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
    • ¥15 错误 LNK2001 无法解析的外部符号
    • ¥50 安装pyaudiokits失败
    • ¥15 计组这些题应该咋做呀
    • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
    • ¥15 让node服务器有自动加载文件的功能