title: PHP file_get_contents works from one server, but gives an authorization error on
body: <p>I've got a script that loads information from another page, using the following code:</p>
  
  <pre><code>    $creds = 'user:password';
  $base64 = base64_encode($creds);
  
  $base_url = 'http://example.com/page.html';
  $data = file_get_contents($base_url.$path, false, $auth);
  </code></pre>
  
  <p>This works fine from one server (my local one, using Ubuntu) but gives me the following headers when run from an external server:</p>
  
  <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
  &lt;html&gt;&lt;head&gt;
  &lt;title&gt;401 Authorization Required&lt;/title&gt;
  &lt;/head&gt;&lt;body&gt;
  &lt;h1&gt;Authorization Required&lt;/h1&gt;
  &lt;p&gt;This server could not verify that you
  are authorized to access the document
  requested.  Either you supplied the wrong
  credentials (e.g., bad password), or your
  browser doesn't understand how to supply
  the credentials required.&lt;/p&gt;
  &lt;hr&gt;
  &lt;address&gt;Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.7a DAV/2 SVN/1.6.6 PHP/5.3.14   JRun/4.0 Server at ww2.rch.org.au Port 80&lt;/address&gt;
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>Is there anything in particular I should be looking for here?  I already have allow_url_fopen set to true on both servers if it helps.</p>
  
  <p><em>Edit:</em> Sorry, there was some other code in there that needed removing.  $auth is as follows:</p>
  
  <pre><code>$auth = stream_context_create(array(
    'http'    =&gt; array(
    'header'  =&gt; 'Authorization: Basic '.$base64
    )
  ));
  </code></pre>
  
  <p>$auth is a stream context, containing the authorization header.</p>