title: POST Request not supported by Google Server
body: <p>I am getting following error while posting request from my server to google.com:</p>
  
  <blockquote>
    <p>Warning: file_get_contents(http://accounts.google.com): failed to open stream: HTTP request failed! HTTP/1.0 405 Method Not Allowed in C:\...\index.php on line 23</p>
  </blockquote>
  
  <p>My code is following:</p>
  
  <pre><code>$postdata = http_build_query(
      array(
          'code'          =&gt; '####',
          'client_id'     =&gt; '####',
          'client_secret' =&gt; '####',
          'grant_type'    =&gt; 'authorization_code'
      )
  );
  
  $opts = array(
      'http' =&gt; array(
          'method'  =&gt; 'POST',
          'header'  =&gt; 'Content-type: application/x-www-form-urlencoded',
          'content' =&gt; $postdata
      )
  );
  
  $context = stream_context_create($opts);
  
  $result = file_get_contents('http://accounts.google.com', false, $context);
  
  echo $result;
  </code></pre>