title: Connect to https server with PHP
body: <p>I need to get data from a webpage on a server which uses the https protocol (i.e. <a href="https://site.com/page" rel="nofollow">https://site.com/page</a>). Here's the PHP code I've been using:</p>
  
  <pre><code>$POSTData = array('');
  $context = stream_context_create(array(
      'http' =&gt; array(
      //'ignore_errors' =&gt; true,
      'user_agent' =&gt; "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36",
      'header' =&gt; "User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/522.11.1 (KHTML, like Gecko) Version/3.0.3 Safari/522.12.1",
      'request_fulluri' =&gt; true,
      'method'  =&gt; 'POST',
      'content' =&gt; http_build_query($POSTData),
      )
  ));
  $pageHTML = file_get_contents("https://site.com/page", FALSE, $context);
  echo $pageHTML;
  </code></pre>
  
  <p>However, this doesn't seem to work, giving out a Warning:  file_get_contents with no information on the error. What might be the case, and how do I work around it to connect to the server and get the page?</p>
  
  <p>EDIT: Thanks to everyone who answered, my problem was that I was using an HTTP proxy, which I removed from the code so that it wouldn't confuse you, as I thought it couldn't possibly have been the problem. To make the code load an HTTPS page via an HTTP proxy, I modified the stream_context_create I used like this:</p>
  
  <pre><code>    stream_context_create(array(
      'https' =&gt; array(
      //...etc
  </code></pre>