首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用params获取请求:未能打开流: HTTP请求失败!HTTP/1.0 403紫禁城

使用params获取请求:未能打开流: HTTP请求失败!HTTP/1.0 403紫禁城
EN

Stack Overflow用户
提问于 2016-06-28 21:06:14
回答 1查看 566关注 0票数 1

我试图使用蒸汽API的新功能,我有麻烦,我认为这是更一般的问题,而不是实际的服务相关本身。

我一直得到:

打开流失败: HTTP请求失败!HTTP/1.0 403紫禁城

我试图使用以下参数发送GET请求:

代码语言:javascript
运行
复制
<?php

    $url = "https://api.steampowered.com/ICSGOTournaments_730/GetTournamentItems/v1?key=".$_SESSION['steam_appid']."&event=9&steamid=".$_SESSION['steam_steamid']."&steamidkey=".$_SESSION['userAuthCode'];
    $response = file_get_contents($url);
    echo($response);

?>

我100%肯定参数是正确的,我认为这与我的代码有关,而不是蒸汽本身。

当我尝试使用相同的代码但使用不同的API调用时:

代码语言:javascript
运行
复制
$url = "https://api.steampowered.com/ICSGOTournaments_730/GetTournamentLayout/v1?key=".$_SESSION['steam_appid']."&event=9";

它执行得很好,并返回数据,因此它与其他两个参数相关。

我想知道我构建URL的方式有什么问题吗?

届会档案(第三缔约方):

代码语言:javascript
运行
复制
<?php
if (empty($_SESSION['steam_uptodate']) or empty($_SESSION['steam_personaname'])) {
    require 'SteamConfig.php';
    $url = file_get_contents("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=".$steamauth['apikey']."&steamids=".$_SESSION['steamid']); 
    $content = json_decode($url, true);
    $_SESSION['steam_appid'] = $steamauth['apikey'];
    $_SESSION['steam_steamid'] = $content['response']['players'][0]['steamid'];
    $_SESSION['steam_communityvisibilitystate'] = $content['response']['players'][0]['communityvisibilitystate'];
    $_SESSION['steam_profilestate'] = $content['response']['players'][0]['profilestate'];
    $_SESSION['steam_personaname'] = $content['response']['players'][0]['personaname'];
    $_SESSION['steam_lastlogoff'] = $content['response']['players'][0]['lastlogoff'];
    $_SESSION['steam_profileurl'] = $content['response']['players'][0]['profileurl'];
    $_SESSION['steam_avatar'] = $content['response']['players'][0]['avatar'];
    $_SESSION['steam_avatarmedium'] = $content['response']['players'][0]['avatarmedium'];
    $_SESSION['steam_avatarfull'] = $content['response']['players'][0]['avatarfull'];
    $_SESSION['steam_personastate'] = $content['response']['players'][0]['personastate'];
    if (isset($content['response']['players'][0]['realname'])) { 
           $_SESSION['steam_realname'] = $content['response']['players'][0]['realname'];
       } else {
           $_SESSION['steam_realname'] = "Real name not given";
    }
    $_SESSION['steam_primaryclanid'] = $content['response']['players'][0]['primaryclanid'];
    $_SESSION['steam_timecreated'] = $content['response']['players'][0]['timecreated'];
    $_SESSION['steam_uptodate'] = time();
    include 'mysql_connection.php';
        $userAuth = getAuth();
        if($userAuth != false){
            $_SESSION['userAuthCode'] = $userAuth;
        }
        else{
            $_SESSION['userAuthCode'] = "Unset";
        }
}

$steamprofile['steamid'] = $_SESSION['steam_steamid'];
$steamprofile['communityvisibilitystate'] = $_SESSION['steam_communityvisibilitystate'];
$steamprofile['profilestate'] = $_SESSION['steam_profilestate'];
$steamprofile['personaname'] = $_SESSION['steam_personaname'];
$steamprofile['lastlogoff'] = $_SESSION['steam_lastlogoff'];
$steamprofile['profileurl'] = $_SESSION['steam_profileurl'];
$steamprofile['avatar'] = $_SESSION['steam_avatar'];
$steamprofile['avatarmedium'] = $_SESSION['steam_avatarmedium'];
$steamprofile['avatarfull'] = $_SESSION['steam_avatarfull'];
$steamprofile['personastate'] = $_SESSION['steam_personastate'];
$steamprofile['realname'] = $_SESSION['steam_realname'];
$steamprofile['primaryclanid'] = $_SESSION['steam_primaryclanid'];
$steamprofile['timecreated'] = $_SESSION['steam_timecreated'];
$steamprofile['uptodate'] = $_SESSION['steam_uptodate'];
?>
EN

回答 1

Stack Overflow用户

发布于 2018-04-09 09:04:30

file_get_contents -对于使用https需要使用:

来自php.net

代码语言:javascript
运行
复制
When using SSL, Microsoft IIS will violate the protocol by closing the 
connection without sending a close_notify indicator. PHP will report 
this as "SSL: Fatal Protocol Error" when you reach the end of the 
data. To work around this, the value of error_reporting should be 
lowered to a level that does not include warnings. PHP can detect 
buggy IIS server software when you open the stream using the https:// 
wrapper and will suppress the warning. When using fsockopen() to 
create an ssl:// socket, the developer is responsible for detecting 
and suppressing this warning.
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38086286

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档