1

我正在使用 fopen 来检索 URL 的内容。它适用于 http URL,但不适用于 https URL

任何人都可以看到为什么?

<?php

//this works fine
echo ("<br><br>url 1 is ".OutputURL("http://nuenergy.acornsoftware.com.au/staff/interface/index.php"));

//returns nothing
echo ("<br><br>url 2 is ".OutputURL("https://nuenergy.acornsoftware.com.au/staff/interface/index.php"));

function OutputURL($url)
{
  $handle = fopen($url, "r");
  $contents = stream_get_contents($handle);
  fclose($handle);
  return $contents;
}
//
?>
4

3 回答 3

5

你需要用 PHP 安装和配置 OpenSSL,我建议你在ServerFault上问这个。

此外,您可以只使用file_get_contents()而不是OutputURL().

于 2010-01-11T06:49:06.080 回答
2

问题不在于 PHP 没有为 HTTPS 返回任何内容,而是您的文件没有为文件的 HTTPS 版本输出任何内容。当我查看 HTTP 版本时,它会输出一个小的 XML 图,表示某种“未找到文件”错误。当我查看文件的 HTTPS 形式时,它返回一个空白页面,源代码中绝对没有内容。您需要查看您的 Apache 配置并确保它正确指向所有文件。

于 2010-01-11T06:38:52.053 回答
0

可能是您的 apache/php 设置不支持通过 fopen 的 https,或者您的服务器的防火墙阻止了这种类型的连接。

于 2010-01-11T06:39:54.823 回答