我想为我的网站登录Steam。我唯一想要的是登录,获取用户名并为该用户启动会话。我按照YouTube上的教程,基本上完成了该视频的所有内容,但是当我通过Steam登录时,我得到:example.com/(()%7D。 代码:
<?php
include "includes/apikey.php";
include "includes/openid.php";
ob_start();
$OpenID = new LightOpenID("http://astral-gaming.com");
session_start();
?>
这是我的标题。另外,我把这个php放在doc的中间(因为我想登录所有navbar元素后出现:
<?php
if(!$OpenID->mode) {
if(isset($_GET['login'])) {
$OpenID->identity = "http://steamcommunity.com/openid";
header("Location: ($OpenID->authUrl()}");
}
if(!isset($_SESSION['T2SteamAuth'])) {
$login = "<li><a href =\"?login\"><img src=\"http://steamcommunity- a.akamaihd.net/public/images/signinthroughsteam/sits_small.png\"/></a></li>";
}
} elseif($OpenID->mode == "cancel"){
} else {
if(!isset($_SESSION['TF2SteamAuth'])) {
$_SESSION['TF2SteamAuth'] = $OpenID->validate() ? $OpenID->identity: null;
$_SESSION['TF2SteamID64'] = str_replace("http://steamcommunity.com/openid/id/", "", $_SESSION['TF2SteamAuth']);
if($_SESSION['TF2SteamAuth'] !== null) {
$Steam64 = str_replace("http:// (ignore space)steamcommunity.com/openid/id/", "", $_SESSION['TF2SteamAuth']);
$profile = file_get_contents("http:// (ignore space) api.steampowered.com/IsteamUser/GetPlayerSummaries/v0002/?key={$api}&steamids=($Steam64)");
$buffer = fopen("cache/{$steam64}.json", "w+");
fwrite($buffer, $profile);
fclose($buffer);
}
header("Location: index.php");
}
}
if(isset($_SESSION['T2SteamAuth'])) {
$login = "<li><a href =\"?logout\">Steam LogOut</a></li>";
}
if(isset($_GET['logout'])) {
unset($_SESSION['T2SteamAuth']);
unset($_SESSION['T2SteamAuth']);
header("Location: index.php");
}
答案 0 :(得分:1)
您的代码中到处都有错误/不匹配的包围/支撑:
header("Location: ($OpenID->authUrl()}");
^-- this should probably be a {?