通过为我的网站设置我的自动捐赠系统,我已经让一切正常,除了最后一页我收到此错误。这是通过Steam的Garrys Mod服务器。
错误:警告:file_get_contents(http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=xxxxxxxxxxxxxxxxxxx&steamids=xxxxxxxxxxxxx) [function.file-get-content]:无法打开流:HTTP 请求失败!HTTP/1.1 401 在/usr/www/angelgaming/public/multiple-rank/inc/page.verify.php 中未授权
验证.php代码:
<?
include('apikey.php');
function toid($friendid) {
if (substr($friendid,-1)%2==0) $server=0; else $server=1;
$auth=bcsub($friendid,'76561197960265728');
$auth=bcsub($auth,$server);
$auth=bcdiv($auth,2);
return "STEAM_0:".$server.':'.$auth;
}
$string = file_get_contents('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=' . $API_KEY . 'steamids=' . $_COOKIE['communityid']);
$json_a = json_decode($string,true);
$steamname = $json_a['response']['players'][0]['personaname'];
$avatar64 = $json_a['response']['players'][0]['avatarfull'];
?>
<h4>Verify the information below before you proceed</h4>
<div id="verify">
<p><b><? echo $steamname; ?></b></p>
<p><img id="avatar" src="<? echo $avatar64; ?>" style="border-radius: 8px;" /></p>
<p><h6>Donation Amount: $<? echo RankPrice($_POST["rank"]) . CURRENCY;?></h6></p>
<br />
<p>
<form name="_xclick" action="https://www.paypal.com/nz/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<? echo PAYPAL_EMAIL; ?>">
<input type="hidden" name="currency_code" value="<? echo CURRENCY; ?>">
<input type="hidden" name="item_name" value="<? echo SERVER_NAME; ?> Donation (<? echo $steamname; ?>)">
<input type="hidden" name="item_number" value="<? echo toid($_COOKIE['communityid']) . '#' . $_POST["rank"]; ?>">
<input type="hidden" name="amount" value="<? echo RankPrice($_POST["rank"]); ?>">
<input role="button" class="btn btn-success" value="Donate" type="submit" alt="Donate to Envidious via PayPal">
<a href="" role="button" class="btn btn-danger">Go Back</a></form>
</div>
如果您转到文档中列出的网址 https://developer.valvesoftware.com/wiki/Steam_Web_API#GetPlayerSummaries_.28v0002.29http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=XXXXXXXXXXXXXXXXXXXXXXX&steamids=76561197960435530
它给出 401,因为它使用了无效密钥 (XXXXXXXX),因为您收到类似的响应,也可能是您发送了无效的 api 密钥或根本没有密钥?
这可能是用户身份验证详细信息问题。我遇到了同样的问题,并通过将用户和密码传递给标头来获得以下解决方案。
https://www.hashbangcode.com/article/using-authentication-and-filegetcontents
由于在.htaccess中启用身份验证模式引起的,例如AuthType Basic指令