2017-06-30 28 views
0

我想用的file_get_contents的file_get_contents不會對工作的一些網址的

$text = @file_get_contents("http://www.kalbam.lt/?feed=rss2"); 

得到一個RRS飼料,但我不知道爲什麼我沒有得到這個網址(PS東西。與其他RSS供稿它作品)。 allow_url_open處於打開狀態。 任何想法?

+0

也許刪除'@'並檢查你的'error.log'?你有'error_reporting'設置? –

+1

閱讀[this](https://stackoverflow.com/questions/26631272/php-file-get-contents-does-not-work-for-some-urls)。 –

+0

錯誤報告設置爲E_ALL –

回答

1

某些服務可以簡單地檢查請求是來自腳本還是來自Web瀏覽器。然後他們可以阻止請求。但爲什麼不製造假頭?

$header=array('GET /1575051 HTTP/1.1', 
'Host: adfoc.us', 
'Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 
'Accept-Language:en-US,en;q=0.8', 
'Cache-Control:max-age=0', 
'Connection:keep-alive', 
'Host:adfoc.us', 
'User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36', 
); 

然後使用curl來檢索數據。

+0

也許我將不得不做這樣的事情。奇怪的情況:P。我會試試這個。 –

+0

好吧,我發現如何去做:) https://stackoverflow.com/questions/2107759/php-file-get-contents-and-setting-request-headers –

相關問題