Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.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 建立名为JSON的语言_Php_Json_Steam - Fatal编程技术网

Php 建立名为JSON的语言

Php 建立名为JSON的语言,php,json,steam,Php,Json,Steam,这是我的问题。我解释: 我使用Firefox。如果将浏览器语言设置为英语,则下一页将显示西班牙语文本,但货币为美元。 同样的URL,如果我将浏览器语言设置为西班牙语,文本将以西班牙语显示,货币为欧元 我用PHP创建了一个使用JSON的脚本:如何设置调用的语言? 以下代码始终返回英语: <?php $url = "http://steamcommunity.com/market/search/render/?l=spanish&start=0&count=20&cu

这是我的问题。我解释:

我使用Firefox。如果将浏览器语言设置为英语,则下一页将显示西班牙语文本,但货币为美元。

同样的URL,如果我将浏览器语言设置为西班牙语,文本将以西班牙语显示,货币为欧元

我用PHP创建了一个使用JSON的脚本:如何设置调用的语言? 以下代码始终返回英语:

<?php
$url = "http://steamcommunity.com/market/search/render/?l=spanish&start=0&count=20&currency=3&category_730_Weapon%5B%5D=tag_weapon_awp&appid=730&query=Man-o%27-war";
$json_object= file_get_contents($url);
$json_decoded = json_decode($json_object);


//precios
preg_match_all('/<span style="color:white">(.*)<\/span>/',$json_decoded->results_html, $sor);

foreach($sor[1] as $k => $v)
{
    echo $v."<br/>";
}

?>

您有一个输入错误。特别是,在你的url中。你说的是
?l=espanish
。它应该是
?l=西班牙语

编辑

不幸的是,我没有更多的答案,但我遇到了以下答案,这可能会有所帮助。似乎显示的货币是上下文相关的-我想您需要通过脚本登录


不管怎样,我希望这有帮助

对于您拥有的货币¤cy= 3:美元
2:€(我相信,试试看)

我修改了apache配置文件。这行:LanguagePriority en cs de fr es it ja ko nl pl pt br ro sv tr被LanguagePriority es en cs de fr it ja ko nl pl pt br ro sv tr更改,但没有正面结果。显示语言仍为英语您看到我的答案了吗?检查我发布的链接-这是修改后的链接,带有正确的西班牙语文本非常感谢Darragh。你的答复帮助我用西班牙语留下了文本。现在的问题是货币仍然是美元。我用upgrade.Hi编辑了这个问题。更新了我的答案。不确定是否有用,但希望是领先。这个答案有用+1,但我的低声誉不允许我投票
<html lang="es">
<head>

<meta http-equiv="Content-Language" content="es"/>

</head>
<body>
<?php

$locale = Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']);
echo $locale."<br/>";

$options = array(
  'http'=>array(
    'method'=>"GET",
    'header'=>"Accept-language: es\r\n" . 
              "Cookie: foo=bar\r\n")
);

$context = stream_context_create($options);

$url = "http://steamcommunity.com/market/search/render/?l=spanish&start=0&count=20&currency=3&category_730_Weapon%5B%5D=tag_weapon_awp&appid=730&query=Man-o%27-war";
$json_object= file_get_contents($url,false,$context);
$json_decoded = json_decode($json_object);


//precios
preg_match_all('/<span style="color:white">(.*)<\/span>/',$json_decoded->results_html, $sor);

foreach($sor[1] as $k => $v)
{
    echo $v."<br/>";
}

?>
</body>
</html>