我正在尝试编写一个Joomla模块,它将从springer api解析json数据。我有问题的方法"file_get_content "以及其他替代品。我的问题是:
Warning: file_get_contents(http://www.example.com) [function.file-get-contents]: failed to open stream: A socket operation was attempted to an unreachable network. in C:'wamp'www'modules'mod_springer'mod_springer.php on line 72
经过一番搜索,我发现这可能是因为我公司的防火墙。是否有任何方法来克服这个问题,如改变端口我正在使用或使用其他方法,或者我被困在这里?
注意:allow_url_fopen是启用的。
如果您能够说服主管人员允许您通过防火墙访问您想要连接的远程API,那么您就不会被卡住。只要您有正当的理由,并且可以在一个狭窄的范围内(一个特定的IP和端口)提供防火墙访问,我不明白为什么您获得此访问会有问题。
- 下载
cacert.pem
文件 - 复制
cacert.pem
文件到例如c:/wamp/bin/php/extras/ssl
文件夹 - 写入或取消
php.pni
curl.cainfo ="c:/wamp/bin/php/extras/ssl/cacert.pem" and save
- 重启Wamp/Xampp服务器
有可能(也许)克服卷发代理处理的问题,如:
curl_setopt($ch, CURLOPT_PROXY, "http://xxx.xxx.xxx.xxx:8080");
curl_setopt($ch, CURLOPT_PROXYPORT, 8080);
curl_setopt ($ch, CURLOPT_PROXYUSERPWD, "xxx:xxx");
这将取决于一些事情,如您拥有的权限,如果它只是一个被阻塞的端口或如果它是访问控制。