我在远程url上使用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),一切都很好,进行了实时测试(Linux PHP 5.3.13),一切正常,然后我在另一台电脑上进行了本地测试(Windows 5.2.9)。
在最后一种情况下,fopen
挂起,直到它超时为止。
allow_url_fopen
打开了,防火墙应该没有问题(基本上我自称:localhost/mysite
中的localhost/mysite
)
由于我的几个客户报告了这个错误,我希望进一步调查
有什么建议吗
PHP 5.2中有漏洞吗?
URL的语法无效
替换:
$url = 'http://test.mysite.com?foo.php';
带有:
$url = 'http://test.mysite.com/?foo.php';