title: Instagram Get Access Token from Code in PHP
body: <p>Following php code is not working for me to get access token 
  In client id and secret key, i have replaced with my real client id and key.</p>
  
  <pre><code>&lt;?php
  $client_id = 'MY CLIENT ID';
  $client_secret = 'MY CLIENT SECRET';
  $redirect_uri = 'http://localhost/instagram/demo.php';
  $scope = 'basic+likes+comments+relationships';
  
  $url = "https://api.instagram.com/oauth/authorize?client_id=$client_id&amp;redirect_uri=$redirect_uri&amp;scope=$scope&amp;response_type=code";
  
  if(!isset($_GET['code']))
  {
      echo '&lt;a href="'.$url.'"&gt;Login With Instagram&lt;/a&gt;';
  }
  else
  {
      $code = $_GET['code'];
  
  $apiData = array(
    'client_id'       =&gt; $client_id,
    'client_secret'   =&gt; $client_secret,
    'grant_type'      =&gt; 'authorization_code',
    'redirect_uri'    =&gt; $redirect_uri,
    'code'            =&gt; $code
  );
  
  $apiHost = 'https://api.instagram.com/oauth/access_token';
  
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $apiHost);
  curl_setopt($ch, CURLOPT_POST, count($apiData));
  curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($apiData));
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  $jsonData = curl_exec($ch);
  curl_close($ch);
  
  var_dump($jsonData);
  $user = @json_decode($jsonData); 
  
  echo '&lt;pre&gt;';
  print_r($user);
  exit;
  }
  ?&gt;
  </code></pre>
  
  <p>Above code always return false.. I can not figure out why this is not working.</p>
  
  <p>Anybody debug this code and let me know what is problem in my code? </p>