我使用php file_get_contents來獲取網頁。
當我從我的本地主機做的時候,一切正常。
但只要我做到這一點從我的共享主機我收到此錯誤信息:錯誤使用php時訪問被拒絕file_get_content
ERROR
拒絕訪問
訪問的安全策略拒絕
爲您的網絡安全策略可以防止您的請求被允許在這個時候。如果您認爲這不正確,請聯繫您的管理員。
這是標題我回來
array(4) { [0]=> string(22) "HTTP/1.0 403 Forbidden" [1]=> string(23)
"Content-Type: text/html" [2]=> string(17) "Connection: close" [3]=> string(19)
"Content-Length: 353" }
代碼很簡單
$page = file_get_contents('http://www.somedomain.com/');
,如果我嘗試對當前頁面它工作
$page = file_get_contents('http://stackoverflow.com/questions/10565054/error-access-denied-when-using-php-file-get-content');
什麼想法?
您的共享主機是否具有相同的php設置並啓用了fopen url wrappers? –
當我從另一個域中讀取它的工作 – yossi
檢查共享主機中是否禁用了「allow_url_fopen」,我猜測這是導致問題的原因。 –