Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Steam API解码URL json_Php_Json_Steam Web Api - Fatal编程技术网

Php Steam API解码URL json

Php Steam API解码URL json,php,json,steam-web-api,Php,Json,Steam Web Api,我正试图为我在一个包含武器的阵列中得到的不同物体制定一个“回音”价格: 我读过很多关于如何通过Steamapi通过Steammarket获取价格的文章: (这些来源都不符合我的要求) 资料来源: 我终于找到了一段完美无瑕的代码片段 文件marketprices.php <?php $items = array("Exalted Manifold Paradox","Kinetic Gem","Mercurial's Call"); foreach($ite

我正试图为我在一个包含武器的阵列中得到的不同物体制定一个“回音”价格:

我读过很多关于如何通过Steamapi通过Steammarket获取价格的文章:
(这些来源都不符合我的要求) 资料来源:


我终于找到了一段完美无瑕的代码片段

文件marketprices.php

<?php

     $items = array("Exalted Manifold Paradox","Kinetic Gem","Mercurial's Call");
        foreach($items as $item)
        {
            $json = json_decode(file_get_contents("http://steamcommunity.com/market/priceoverview/?appid=570&market_hash_name=".rawurlencode($item)), true);
            if($json["success"] == true OR !empty($json))
            {
                echo $item."'s lowest price is ".$json["lowest_price"]."";
            }
            elseif($json["success"] == false OR empty($json))
            {
                echo "Could not get data for ".$item;
            }
        }
资料来源:

到目前为止还不错

我得到了错误的结果 下面是我的代码:

foreach($S_W as $item)
{
    $json = json_decode(file_get_contents("http://steamcommunity.com/market/priceoverview/?appid=570&market_hash_name=".rawurlencode($item)), true);
    if($json["success"] == true OR !empty($json))
    {
        echo $item."'s lowest price is ".$json["lowest_price"]."";
    }
    elseif($json["success"] == false OR empty($json))
    {
        echo "Could not get data for ".$item;
    }
}
我收到以下结果:

我看到了部分错误。。 在URL末尾的调用中,代码添加:
/br

有人能帮我解决吗

先谢谢你

致意


丹尼尔(Daniel)

价格概述“API”终点的速率受蒸汽限制,最近更进一步受阀门的速率限制。你收到了429个HTTP状态码,表示“请求太多”,你太频繁地向他们的站点发送请求。

是上面来自
MarketPrices.php
的代码片段,他们是否显示了有问题的行?@Daniellmnas:
/br
的解码值是

。这意味着该值有一个换行符。首先试试PHP的
strip_tags()
。你能详细解释一下我是PHP新手吗。你能给我一个片段吗?谢谢你的光临advance@DanielElmnas:此外,您还有一个
&。并删除您发布的答案,因为它不是答案。您应该更新您的问题。@daniellmnas:change
570/market\u hash\u name
改为
570&market\u hash\u name
。它为您提供了一些json。不过,我不熟悉steam API的工作原理。其他人如何解决从价目表创建数组的问题?谢谢你的光临advance@DanielElmnas一种方法是每分钟发送x个请求,我相信可能是每分钟20个请求。如果我每分钟发送x个请求,你应该怎么做?如果不难的话,你能帮我举个例子吗。通过使用我正在使用的方法。这是最简单的方法吗?提前感谢您刚刚注意到您发送的CS:GO项目的appID不正确,570用于Dota 2,730用于CS:GO。
When I am trying to implent this snippet to my code I get error in my result:

I have created an array that contains different weapons:
<?
    foreach($S_W as $item) // Steam weapon
    {
    echo $item;
    }

?>
AWP | Worm God (Factory New)
FAMAS | Cyanospatter (Field-Tested)
G3SG1 | Green Apple (Factory New)
G3SG1 | Polar Camo (Field-Tested)
Glock-18 | Death Rattle (Field-Tested)
M249 | Gator Mesh (Field-Tested)
MAC-10 | Heat (Field-Tested)
foreach($S_W as $item)
{
    $json = json_decode(file_get_contents("http://steamcommunity.com/market/priceoverview/?appid=570&market_hash_name=".rawurlencode($item)), true);
    if($json["success"] == true OR !empty($json))
    {
        echo $item."'s lowest price is ".$json["lowest_price"]."";
    }
    elseif($json["success"] == false OR empty($json))
    {
        echo "Could not get data for ".$item;
    }
}