开发者

Cant open a https website with php and fopen

开发者 https://www.devze.com 2022-12-16 03:59 出处:网络
I am using fopen to retreive the contents of a URL. It works on http URLs but not https URLs Can anyone see why??

I am using fopen to retreive the contents of a URL. It works on http URLs but not https URLs

Can anyone see why??

<?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;
}
//
?>


You need to have OpenSSL installed and configured with PHP, I recommend you ask this on ServerFault.

Also, you can just use file_get_contents() instead of OutputURL().


The problem isn't with PHP not returning anything for HTTPS, it's your file not outputting anything for the HTTPS version of the file. When I view the HTTP version, it outputs a small XML diagram representing some sort of 'File Not Found' error. When I view the HTTPS form of the file, it returns a blank page, absolutely no content in the source code. You need to look at your Apache configurations and make sure it's pointing to all the files properly.


It'll either be that your apache/php setup does not support https via fopen or your server's firewall has blocked this type of connection.

0

精彩评论

暂无评论...
验证码 换一张
取 消