我正在开发一个项目,我需要从另一台服务器获取.htm文件。
但是file_get_contents()
似乎不起作用,因为它总是返回这个:
file_get_contents(https://hvgg.de/):无法打开流:连接超时
这是我的代码
$url = "https://hvgg.de/vplan/f" . $day . "/subst_001.htm";
$opts = array("http" =>
array("header" => "Connection: close")
);
$context = stream_context_create($opts);
$f = file_get_contents($url, false, $context);
如果我在本地主机上运行相同的代码,那么一切都运行良好并且很快。
这是我的php.ini
:
allow_url_fopen On
allow_url_include Off
always_populate_raw_post_data Off
注意:我尝试访问的服务器使用ssl和ssl证书(据我所知)未经授权机构授权。
我也尝试了cURL,它也没有真正起作用,这是curl_getinfo()
返回的输出:
Array
(
[url] => https://hvgg.de/
[content_type] =>
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 63.11468
[namelookup_time] => 0.005179
[connect_time] => 0
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0
[certinfo] => Array
(
)
[primary_ip] => 89.19.241.160
[primary_port] => 443
[local_ip] =>
[local_port] => 0
[redirect_url] =>
)
关于我能做什么的任何想法?
我还读到,由于IPv6或我的/etc/resolv.conf
,这可能是错误。可能是这样吗?