title: Why am I getting this error with a PHP cURL request to the GitHub API when it works fine in Postman?
body: <p>I have a valid OAuth token that I'm using to make GitHub API requests to retrieve information about my private repos.</p>
  
  <p>By referencing the GitHub API documentation (<a href="https://developer.github.com/v3/" rel="nofollow noreferrer">https://developer.github.com/v3/</a>), I'm able to use the token to make valid requests from Postman about my private repos with the following headers (note that the token below is not my real token):</p>
  
  <pre><code>Accept: application/vnd.github.v3+json
  Authorization: token 5c67da5c67f5d67ac5ff5acdf675facbe875t86a
  </code></pre>
  
  <p>However, when I try to use the PHP cURL code below to make the same API calls, I get back the following error message:</p>
  
  <pre><code>Request forbidden by administrative rules. Please make sure your request has a User-Agent 
  header (http://developer.github.com/v3/#user-agent-required). 
  Check https://developer.github.com for other possible causes.
  </code></pre>
  
  <p>Why am I getting this message, even though I'm sending over valid headers?<br>
  The GitHub URL linked in the error message even says the following:</p>
  
  <blockquote>
    <p>We request that you use your GitHub username, or the name of your
    application, for the User-Agent header value.</p>
  </blockquote>
  
  <p>I'm sending my GitHub username as the value for the <code>User-Agent</code> header, but it doesn't change anything.<br>
  What am I doing wrong?</p>
  
  <p>PHP cURL code:
      
  
  <pre><code>  $ch = curl_init('https://api.github.com/repos/GitHub-username/repo-name/contents/directory-in-repo');
  
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
      'Accept' =&gt; 'application/vnd.github.v3+json',
      'Authorization' =&gt; 'token 5c67da5c67f5d67ac5ff5acdf675facbe875t86a',
      'User-Agent' =&gt; 'GitHub-username'
    ]);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  
    $json = curl_exec($ch);
    curl_close($ch);
  
    echo $json; // This outputs the error above.
  </code></pre>
  
  <hr>
  
  <p><strong>Edit #1</strong>:</p>
  
  <p>Based on the comment from jake2389, I tried using a real user-agent string, but it still didn't work. Specifically, for the <code>User-Agent</code> header, I tried my browser's current user-agent string (the following), but I still got the same error:</p>
  
  <pre><code>Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.119 Safari/537.36
  </code></pre>
  
  <p>I then tried the exact user-agent string that jake2389 recommended, and I got the following response:</p>
  
  <p><a href="https://i.stack.imgur.com/TZ4Fs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TZ4Fs.png" alt="GitHub error"></a></p>
  
  <p>I have no clue why one (valid) user-agent string versus another produces two different results, but all the same, neither works.<br>
  I'm still not sure what to do.<br>
  Thanks.</p>