title: What does it mean if file_get_contents returns "HTTP request failed! HTTP/1.1 403"?
body: <p>This error is seems to come every time </p>
  
  <pre><code> file_get_contents(https://api.github.com/users/AnyUsername/following): failed 
   to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in 
   C:\xampp\htdocs\Github\test.php on line 40
  </code></pre>
  
  <p>Below are some of the lines of code:</p>
  
  <pre><code>$data = array(
  'client_id' =&gt; 'a7f10b4ef02b11843ae7',
  'client_secret' =&gt; '89b227cbb3705099c7281ba367cfc5f868ea4f4b',
  'redirect_uri'=&gt;'http://localhost/Github/test.php',
  'code'=&gt;$code,
  
  );
  
  $post=http_build_query($data);
  $url="https://github.com/login/oauth/access_token?".$post;
  $contents=file_get_contents($url);
  $explode1 = explode('access_token=', $contents);
  $explode2 = explode('&amp;scope=user', $explode1[1]);
  $access_token = $explode2[0];
  $opts = [ 'http' =&gt; [
             'method' =&gt; 'GET',
             'header' =&gt; [ 'User-Agent: PHP']
                  ]
      ];
      //fetching user data
  $url = "https://api.github.com/user?access_token=".$access_token;
  $context = stream_context_create($opts);
  $data = file_get_contents($url, false, $context);
  $user_data = json_decode($data, true);
  $_SESSION['user'] = $user_data['login'];
  $_SESSION['email']=$user_data['email'];
  $img=$user_data['avatar_url'];
  $name=$user_data['name'];
  
      //fetching user following
  $url="https://api.github.com/users/".$_SESSION['user']."/following";
  $context = stream_context_create($opts);
  $data = file_get_contents($url, false, $context);
  $user_data = json_decode($data, true);
  </code></pre>
  
  <p>The error is in second last line, this is generally a GitHub API
  through PHP.</p>