首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Steam解码URL json

Steam解码URL json
EN

Stack Overflow用户
提问于 2016-02-16 17:39:31
回答 1查看 853关注 0票数 1

我正在尝试为我在包含武器的数组中获得的不同对象创建一个“回声”价格:

我读了很多关于如何通过Steamapi通过Steammarket获得价格的文章:

(这些来源都不符合我的要求)来源:

Get steam item prices

How get a response of multiple price items on the market

Get the price of an item on Steam Community Market with PHP and Regex

我终于找到了一个可以完美工作的代码片段。

文件marketprices.php

代码语言:javascript
运行
复制
<?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;
            }
        }

output>

代码语言:javascript
运行
复制
Exalted Manifold Paradox's lowest price is $28.49Kinetic Gem's lowest price is $50.00Mercurial's Call's lowest price is $0.16

来源:http://gamebanana.com/tuts/11942

代码语言:javascript
运行
复制
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;
    }

?>

output>

代码语言:javascript
运行
复制
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)

到目前为止还不错..

I get error in the result以下是我的代码:

代码语言:javascript
运行
复制
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末尾的调用中,代码添加了:&lt;/br&gt;

有没有人能帮我解决这个问题?

提前谢谢你

诚挚的问候

丹尼尔

EN

回答 1

Stack Overflow用户

发布于 2016-02-22 03:42:52

Priceoverview 'API‘端点受到Steam的速率限制,最近甚至受到Valve的速率限制。你得到了429 HTTP状态码,它代表“太多的请求”,你向他们的站点发送请求的方式太频繁了。

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35428817

复制
相关文章

相似问题

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