带有 cookie 的 curl json 返回 “‹ŠŽÿÿ)»L”


curl json with cookie returns "‹ŠŽÿÿ)»L"

我正在尝试获取此json的内容:http://steamcommunity.com/market/pricehistory/?country=DE&currency=3&appid=730&market_hash_name=Chroma%20Case

这是我的代码:

$url = "http://steamcommunity.com/market/pricehistory/?country=DE&currency=3&appid=730&market_hash_name=Chroma%20Case";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIE, 'steamLogin = 76561198075419487%7C%7C3F1A776553C4BE1D0F6DA83059052E79DB7EB3C7');
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
$json_string = json_encode($output, JSON_PRETTY_PRINT);

打印出$json_string时,它没有任何结果,$output结果为"‹ŠŽÿÿ)»L"。我想获取网站上的实际内容,为此需要steamLogin -Cookie。目前存储在浏览器中的cookie是我在源代码中硬编码的cookie。

如果您需要更多信息,请随时询问。

添加curl_setopt($ch, CURLOPT_ENCODING,"");使其:)