好吧,我在网站上通过Steam登录时遇到了一些问题。代码似乎可以解决,直到您按“是,登录”。在这里:Screenshot。
点击“是,登录”。按钮它将我重定向回登录按钮所在的页面,并且登录按钮不可见,就像它工作但脚本注销按钮也不存在。它只是一个空白页面,它有一个非常长的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
登录按钮也会在页面刷新后返回。
这是代码,我正在使用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}\"/>";
}
?>