file_get_contents和curl不起作用,tcp端口阻塞问题
我正在尝试编写一个 Joomla 模块,它将解析来自 springer api 的 json 数据。我对“file_get_contents”方法和其他替代方法有问题。我的问题是:
警告:file_get_contents(http://www.example.com) [function.file-get-contents]:无法打开流:尝试对无法访问的网络进行套接字操作。在 C:\wamp\www\modules\mod_springer\mod_springer.php 第 72 行
经过一番查找,发现可能是因为我公司的防火墙的原因。有什么方法可以解决这个问题,例如更改我正在使用的端口或使用其他方法,还是我被困在这里?
注意:allow_url_fopen 已启用。我用的是wamp
I'm trying to write a Joomla module which will parse json data from springer api. I have problem with the method "file_get_contents" and other replacements. My problem is that:
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
After some search, I found out that it may be because of my company's firewall. Is there any way to overcome this problem like changing port I'm using or using another method, or am I stuck here?
Note: allow_url_fopen is enabled. I'm using wamp.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您能够说服当权者允许您通过防火墙访问您想要连接的远程 API,那么您就不会陷入困境。只要您有合法的理由并且可以在狭窄的范围内(一个特定的 IP 和端口)配置防火墙访问,我不明白为什么您在获取此访问时会遇到问题。
You're not stuck if you can convince the powers-that-be to allow you access through the firewall to the remote API to which you wish to connect. As long as you have a legitimate reason and the firewall access can be provisioned in a narrow scope (one specific IP and port), I don't see why you should have a problem getting this access.
cacert.pem
文件cacert.pem
文件到例如c:/wamp/bin/php/extras/ssl
文件夹php.pni
curl 中写入或取消注释。卡信息="c:/wamp/bin/php/extras/ssl/cacert.pem" 并保存
cacert.pem
file from herecacert.pem
file to for examplec:/wamp/bin/php/extras/ssl
folderphp.pni
curl.cainfo ="c:/wamp/bin/php/extras/ssl/cacert.pem" and save
可能(也许)可以通过 cURL 代理处理来解决这个问题,例如:
这取决于一些因素,例如您拥有的权限,是否只是被阻止的端口或是否是访问控制。
It may be possible (MAYBE) to overcome the issue with cURLs proxy handling like:
This would depend on a few things like the permissions you have, if it is just a blocked port or if it is access control.