title: Making a php OAuth request to Discord
body: <p>Been struggling for a while. Trying to get my token from discord.</p>
  
  <p>Please let me know where I am going wrong.</p>
  
  <pre><code>&lt;?php
  ini_set('display_errors',1);
  
  $code = '';
  $code = $_GET['code'];
  
  if(isset($code)){
  
  $postData = array(
      'code' =&gt; $code,
      'client_id' =&gt; "[omitted]",
      'client_secret' =&gt; '[omitted]',
      'redirect_uri' =&gt; '[omitted]'
  );
  
  // Create the context for the request
  $context = stream_context_create(array(
      'http' =&gt; array(
          // http://www.php.net/manual/en/context.http.php
          'method' =&gt; 'POST',
          'content' =&gt; $postData,
                  'header' =&gt; "Authorization: Bot [omitted]\r\n".
          "Content-Length: ".strlen($postData)."\r\n",
      )
  ));
  
  // Send the request
  $response = file_get_contents('https://discordapp.com/api/oauth2/authorize', FALSE, $context);
  
  echo $response;
  
  } else {
      echo '&lt;a href="https://discordapp.com/oauth2/authorize?response_type=code&amp;redirect_uri=[omitted]&amp;scope=identify%20guilds&amp;client_id=[omitted]"&gt;Login&lt;/a&gt;';
  }
  </code></pre>
  
  <p>I keep getting the error</p>
  
  <blockquote>
    <p>Warning: file_get_contents(<a href="https://discordapp.com/api/oauth2/authorize" rel="nofollow noreferrer">https://discordapp.com/api/oauth2/authorize</a>): failed to open stream: HTTP request failed! HTTP/1.1 411 Length Required in /index.php on line 27</p>
  </blockquote>