title: Google App Engine (PHP) - file_get_contents with URL returns false
body: <p>I'm using google app engine locally and the request returns what it should.</p>
  
  <p>Then I try on google app engine (the appspot service myapp.appspot.com) and the exact same call simply returns false without any errors.</p>
  
  <p>The php documentation says I should get an error or a warning but I really don't see anything.
  <a href="http://www.php.net/manual/en/function.file-get-contents.php" rel="nofollow noreferrer">http://www.php.net/manual/en/function.file-get-contents.php</a></p>
  
  <p>I found this gae php documentation below but I really can't figure out what could be wrong.
  <a href="https://developers.google.com/appengine/docs/php/urlfetch/" rel="nofollow noreferrer">https://developers.google.com/appengine/docs/php/urlfetch/</a></p>
  
  <p>I'm trying to fetch an url of another app from the appspot and the gae doc says:</p>
  
  <blockquote>
    <p>Making requests to another App Engine app</p>
    
    <p>If you are making requests to another App Engine app, you should
    consider telling the URL Fetch service to not follow redirects when
    invoking it.</p>
  </blockquote>
  
  <p>Does anyone know how do I do that, or maybe what could even be the real problem ?</p>
  
  <p>Here is my snippet:</p>
  
  <pre><code>    $content = file_get_contents($url, 0, $context);
      if (false === $content) {
          $error = error_get_last();
          throw new ClientException($error['message']);
      }
  </code></pre>
  
  <p><strong>UPDATE</strong>:</p>
  
  <p>Here is my php.ini:</p>
  
  <pre><code>google_app_engine.enable_functions = "php_sapi_name, php_uname, getmypid"
  google_app_engine.allow_include_gs_buckets = "storage_bucket_name"
  allow_url_include=1
  allow_url_fopen=1
  </code></pre>
  
  <p>I tried with the following code:</p>
  
  <pre><code>    error_reporting(-1);
      ini_set('display_errors', 1);
      $content = file_get_contents($url, 0, $context);
      if (false === $content) {
          $error = error_get_last();
          throw new ClientException($error['message']);
      }
  </code></pre>
  
  <p>Now I get this error: "failed to open stream: Invalid headers. Must be a string."</p>
  
  <p>This is my $context variable which is passed through stream_context_create():
  <a href="http://www.php.net/manual/fr/function.stream-context-create.php" rel="nofollow noreferrer">http://www.php.net/manual/fr/function.stream-context-create.php</a></p>
  
  <pre><code>array(2) {
    ["http"]=&gt;
    array(7) {
      ["method"]=&gt;
      string(3) "GET"
      ["header"]=&gt;
      string(0) ""
      ["content"]=&gt;
      NULL
      ["protocol_version"]=&gt;
      float(1)
      ["ignore_errors"]=&gt;
      bool(true)
      ["max_redirects"]=&gt;
      int(5)
      ["timeout"]=&gt;
      int(5)
    }
    ["ssl"]=&gt;
    array(1) {
      ["verify_peer"]=&gt;
      bool(true)
    }
  }
  </code></pre>
  
  <p>This is leading me to that old thread:</p>
  
  <p><a href="https://stackoverflow.com/questions/22071860/using-file-get-contents-invalid-headers-issue-on-gae">Using file_get_contents invalid headers issue on GAE</a></p>