我试图编写一个joomla模块,它将解析来自springer api的json数据。我有方法“file_get_contents”和其他替换问题。我的问题是:
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已启用。我正在使用wamp。
提前致谢,
伊斯梅尔
如果你可以说服权力允许你通过防火墙访问你想要连接的远程API,那么你就不会陷入困境。只要您有合法的理由并且可以在狭窄的范围(一个特定的IP和端口)中配置防火墙访问,我就不明白为什么您应该在获取此访问权限时遇到问题。
有可能(MAYBE)克服cURLs代理处理的问题,如:
curl_setopt($ch, CURLOPT_PROXY, "http://xxx.xxx.xxx.xxx:8080");
curl_setopt($ch, CURLOPT_PROXYPORT, 8080);
curl_setopt ($ch, CURLOPT_PROXYUSERPWD, "xxx:xxx");
这取决于您拥有的权限,如果它只是一个被阻止的端口或它是否是访问控制。
我希望这对你有所帮助,祝你好运
cacert.pem
下载here文件cacert.pem
文件复制到例如c:/wamp/bin/php/extras/ssl
文件夹php.pni
curl.cainfo ="c:/wamp/bin/php/extras/ssl/cacert.pem" and save
中写或取消注释