2017-04-23 111 views
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��% 
+0

您是否嘗試過使用curl來代替file_get_contents? – Peter

+0

當我使用curl時,它返回: + O %。 –

+0

用代碼更新你的問題你試過 – Peter

回答

0

我的域名被臨時從發出請求的URL取締。我在另一臺服務器上測試了代碼,它工作正常。

相關問題