0
我试图使用蒸汽API,但每当我使用的file_get_contents()与蒸汽社区网址我得到这个错误:file_get_contents()在特定的URL上失败:未能打开流:HTTP请求失败! HTTP/1.0 429
Warning: file_get_contents(http://steamcommunity.com/market/priceoverview/?currency=1&appid=578080&market_hash_name=Gas%20Mask): failed to open stream: HTTP request failed! HTTP/1.0 429
如果我使用file_get_contents()函数在Google.com上,例如,它返回的页面没有错误。我试图使用curl,它只是返回随机字符。下面是我使用的代码:
// create curl resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, "http://steamcommunity.com/market/priceoverview/?currency=1&appid=578080&market_hash_name=Gas%20Mask");
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
$output = curl_exec($ch);
// close curl resource to free up system resources
curl_close($ch);
echo $output;
结果:
��+��O��%
您是否尝试过使用curl来代替file_get_contents? – Peter
当我使用curl时,它返回: + O %。 –
用代码更新你的问题你试过 – Peter