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/mysite
从localhost/mysite
)
由于几个矿山的客户报告这个错误我想进一步调查。
有什么建议吗?
在PHP 5.2中有错误吗?
对不起,我输入了错误的URL。现在它是正确的 – tampe125