title: Using discord API with PHP & cURL
body: <p>i've made a bot on discord, and i want to make request to the API to manage channels, display messages, those kind of things.
  I've started by using Postman, to make some calls to the API, it works fine.</p>
  
  <p>Link to the API : <a href="https://discordapp.com/developers/docs/intro" rel="noreferrer">https://discordapp.com/developers/docs/intro</a></p>
  
  <p>Then i tried to do the request using PHP(wamp), with cURL, the request is sent, but the API send me back a 401 Unauthorized response, despite the fact that I sent the correct Authorization header.
  I've added the verbose option to get more infos :</p>
  
  <pre><code>* Hostname in DNS cache was stale, zapped
  
  *   Trying 104.16.58.5...
  
  * Connected to discordapp.com (104.16.58.5) port 443 (#0)
  
  * ALPN, offering http/1.1
  
  * Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
  
  * SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
  
  * ALPN, server accepted to use http/1.1
  * Server certificate:
  
  *    subject: OU=Domain Control Validated; OU=PositiveSSL; CN=discordapp.com
  
  *    start date: 2016-03-01 00:00:00 GMT
  
  *    expire date: 2017-03-03 23:59:59 GMT
  
  *    subjectAltName: discordapp.com matched
  
  *    issuer: C=GB; ST=Greater Manchester; L=Salford; O=COMODO CA Limited; CN=COMODO RSA Domain Validation Secure Server CA
  
  *    SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
  &gt; GET /api/channels/230833430827499520/messages HTTP/1.1
  Host: discordapp.com
  Accept: */*
  Authorization : Bot &lt;TOKEN&gt;
  
  &lt; HTTP/1.1 401 UNAUTHORIZED
  &lt; Date: Sat, 01 Oct 2016 01:23:22 GMT
  &lt; Content-Type: application/json
  &lt; Content-Length: 43
  &lt; Connection: keep-alive
  &lt; Set-Cookie: __cfduid=d23fd84fe760ad0b225004284861067621475285002; expires=Sun, 01-Oct-17 01:23:22 GMT; path=/; domain=.discordapp.com; HttpOnly
  &lt; Strict-Transport-Security: max-age=31536000; includeSubDomains
  &lt; Via: 1.1 google
  &lt; Alt-Svc: clear
  &lt; Server: cloudflare-nginx
  &lt; CF-RAY: 2eac1be3385d148b-AMS
  &lt; 
  * Connection #0 to host discordapp.com left intact
  </code></pre>
  
  <p>My code :</p>
  
  <pre><code>$url = 'https://discordapp.com/api/channels/230833430827499520/messages';
  
  $ch = curl_init();
  $f = fopen('request.txt', 'w');
  curl_setopt_array($ch, array(
      CURLOPT_URL            =&gt; $url, 
      CURLOPT_HTTPHEADER     =&gt; array('Authorization : Bot &lt;TOKEN&gt;'), 
      CURLOPT_RETURNTRANSFER =&gt; 1,
      CURLOPT_FOLLOWLOCATION =&gt; 1,
      CURLOPT_VERBOSE        =&gt; 1,
      CURLOPT_SSL_VERIFYPEER =&gt; 0,
      CURLOPT_STDERR         =&gt; $f,
  ));
  $response = curl_exec($ch);
  fclose($f);
  curl_close($ch);
  </code></pre>
  
  <p>I tried <code>file_get_contents</code> as well but didn't work.
  I can't see what's wrong, maybe SSL certificate?
  Any thoughts?</p>