Instagram Obtenir un Jeton d'Accès de Code en PHP

Suivants du code php ne fonctionne pas pour moi d'obtenir un jeton d'accès
Dans l'id client et la clé secrète, je l'ai remplacé par mon client id et key.

<?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&redirect_uri=$redirect_uri&scope=$scope&response_type=code";

if(!isset($_GET['code']))
{
    echo '<a href="'.$url.'">Login With Instagram</a>';
}
else
{
    $code = $_GET['code'];

$apiData = array(
  'client_id'       => $client_id,
  'client_secret'   => $client_secret,
  'grant_type'      => 'authorization_code',
  'redirect_uri'    => $redirect_uri,
  'code'            => $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 '<pre>';
print_r($user);
exit;
}
?>

Code ci-dessus retourne toujours faux.. je ne peux pas comprendre pourquoi cela ne fonctionne pas.

Quelqu'un de débogage de ce code et laissez-moi savoir quel est le problème dans mon code?

OriginalL'auteur Kliptu | 2013-02-27