我在本地主机中使用此代码
include "apikey.php"; // My api key
include "OpenId.php"; //Official light open id lib.
$OpenID = new LightOpenID("http://4pstore.com/");
$api = B5F1409CA6FFE70A2CFB98C870A6A9F5;
session_start();
if(!$OpenID->mode){
if(isset($_GET['login'])){
$OpenID->identity = "http://steamcommunity.com/openid";
header("Location: {$OpenID->authUrl()}");
}
if(!isset($_SESSION['T2SteamAuth'])){
echo "<a href=\"?login\"><img src=\"http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_small.png\" border=\"0\"/></a>";
}
} elseif($OpenID->mode == "cancel"){
echo "User has canceled Authenticiation.";
} 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={$api}&steamids={$Steam64}");
$buffer = fopen("cache/{$Steam64}.json", "w+");
file_put_contents("cache/{$Steam64}.json", $profile);
fclose($buffer);
}
header("Location: index.php");
}
}
if(isset($_SESSION['T2SteamAuth'])){
echo "<div id=\"login\"><a href=\"?logout\">Logout</a></div>";
$steam = json_decode(file_get_contents("cache/{$_SESSION['T2SteamID64']}.json"));
echo "<img src=\"{$steam->response->players[0]->avatarfull}\"/>";
}
if(isset($_GET['logout'])){
unset($_SESSION['T2SteamAuth']);
unset($_SESSION['T2SteamID64']);
header("Location: index.php");
}
它有结果,可以访问蒸汽信息,图片一切,它写入文件名 76561198023220354.json 像这样
{
"response": {
"players": [
{
"steamid": "76561198023220354",
"communityvisibilitystate": 3,
"profilestate": 1,
"personaname": "KLoGic",
"lastlogoff": 1399082572,
"profileurl": "http://steamcommunity.com/id/klogic/",
"avatar": "http://media.steampowered.com/steamcommunity/public/images/avatars/ee/eef75511ba1f16b66e9ac45346e7c0f790a6551a.jpg",
"avatarmedium": "http://media.steampowered.com/steamcommunity/public/images/avatars/ee/eef75511ba1f16b66e9ac45346e7c0f790a6551a_medium.jpg",
"avatarfull": "http://media.steampowered.com/steamcommunity/public/images/avatars/ee/eef75511ba1f16b66e9ac45346e7c0f790a6551a_full.jpg",
"personastate": 1,
"realname": "KLoGic",
"primaryclanid": "103582791433445765",
"timecreated": 1269915414,
"personastateflags": 0,
"loccountrycode": "TH"
}
]
}
}
但是当我在我的网站上使用这个代码时,它无法访问蒸汽信息,图片所有内容和文件 76561198023220354.json 它只说
<html> <head> <title>404 Not Found</title> </head> <body> <h1>Not Found</h1> </body> </html>
请帮帮我 :(