2012-09-12 69 views
0

我在遠程網址上遇到fopen錯誤。fopen無法打開遠程網址

我必須發佈一些XML數據到另一臺服務器:因爲我想避免curl庫未安裝的問題,我更喜歡使用流。

這是我的代碼:

$url = 'http://test.mysite.com/index.php?foo=bar'; 
$params = array('http' => array('method' => 'POST','content' => $data)); 
$ctx = stream_context_create($params); 
$fp = fopen($url, 'rb', false, $ctx); 

if (!$fp) { 
    throw new Exception("Problem with $url, $php_errormsg"); 
} 
$response = stream_get_contents($fp); 

我在本地計算機上測試(Windows中,PHP 5.3.8)和寄託都被罰款,現場測試(PHP的Linux 5.3.13),並處於正常狀態,那麼我在另一臺電腦上本地測試(Windows 5.2.9)。
那麼在這最後一種情況下,fopen會掛起,直到超時。

allow_url_fopen是,應該有防火牆沒有問題(基本上我打電話我:localhost/mysitelocalhost/mysite

由於幾個礦山的客戶報告這個錯誤我想進一步調查。
有什麼建議嗎?
在PHP 5.2中有錯誤嗎?

回答

1

您的URL的語法無效。
替換:

$url = 'http://test.mysite.com?foo.php'; 

有了:

$url = 'http://test.mysite.com/?foo.php'; 
+0

對不起,我輸入了錯誤的URL。現在它是正確的 – tampe125