title: GAE, PHP and GCM: failed to open stream: HTTP request failed! HTTP/1.0 405 Method Not Allowed
body: <p>I'm developing a web application (using GAE for PHP) that notifies android clients (via GCM - Google Cloud Messaging) when some content are available for download.</p>
  
  <p>The following PHP script should do job:</p>
  
  <pre><code>$json = array( 
      'data' =&gt; array( ... ), 
      'registration_ids' =&gt; array( ... )
  );
  
  $data = json_encode( $json );
  $context = array( 
      'http' =&gt; array(
          'method' =&gt; 'post',
          'header' =&gt; 'Authorization: key=MY_SECRET_KEY' . "\r\n" .
                      'Content-Type: application/json' . "\r\n",
          'content' =&gt; $data
      )
  );
  $context = @stream_context_create($context);
  $result = @file_get_contents("https://android.googleapis.com/gcm/send", false, $context);
  </code></pre>
  
  <p>The above code runs correctly when the app is deployed, but do not when running on my local development environment.</p>
  
  <p>On local development environment <code>$result</code> is <code>null</code> and the <code>file_get_contents</code> "echo" the following warning <code>failed to open stream: HTTP request failed! HTTP/1.0 405 Method Not Allowed</code>.</p>