PHP get_headers和curl都给出空结果 [英] PHP get_headers and curl both give empty result

查看:61
本文介绍了PHP get_headers和curl都给出空结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有一些类似的话题,但不尽相同.我有一个有效的代码,并用很多不同的URL(以及http和https)进行了测试,没有任何问题.然后,我找到了一个网站...当我询问URL标头时,我得到了一个空数组答案.

I know there is some similar topic, but not the same. I have a working code, tested with a lot of different url - http and https as well - without any problem. Then, I found a website ... when I asking the URL header, I got empty array answer.

get_headers("https://www.diversalertnetwork.org/diving-incidents/Divers-air-consumption-appeared-unbelievably-good", 1);

结果是一个EMPTY数组.

And the result is an EMPTY array.

Array
(
)

我也尝试使用CURL,但结果相同.我尝试下载url的内容,但没有下载任何内容.你可以试试看.惊喜!如果我从https://修改为http://,它将开始工作.当然,https链接在浏览器中效果很好.另外,get_headers与其他https://链接一起使用.使用curl时,我使用自己的浏览器的useragent,因此如果服务器出于任何安全原因而尝试检测,则这是真实的.我真的不知道该怎么办,最重要的是,发生了什么,为什么没有任何答案,没有错误等等.

I am also try with CURL but same result. I try to download the url's content but nothing. You can try it. Surprise! If I modify to http:// from https://, it will start working. Of course, the https link working very well in a browser. Also, the get_headers working with other https:// links. With curl I using my own browser's useragent, so that is a real if the server try to detect for any security reason. I really do not know what can I do, and most important, what happening, why there is no any answer, not an error or whatever.

php 5.6

推荐答案

我的浏览器显示有关该站点的HTTPS连接的警告:

My browser shows warning about that site's HTTPS connection:

与该站点的连接使用了过时的协议(TLS 1.0),过时的密钥交换(RSA)和过时的密码(带有HMAC-SHA1的3DES_EDE_CBC).

The connection to this site uses an obsolete protocol (TLS 1.0), an obsolete key exchange (RSA), and an obsolete cipher (3DES_EDE_CBC with HMAC-SHA1).

因此,可能只是在您的系统上禁用了与仅支持过时的安全协议的站点建立HTTPS连接.

So it might simply be that on your system making HTTPS connections with sites that only support outdated security protocols is disabled.

与SSL相关的Apache配置设置可以在以下位置找到: https://superuser.com/a/882651

Which Apache config settings regarding SSL are relevant, can be found here: https://superuser.com/a/882651

这篇关于PHP get_headers和curl都给出空结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆