I've been working on some IG API and when I try to get the IG username I get this error
I just don't see anything wrong with my code did I miss something ??
( ! ) Notice: Undefined index: user in C:\wamp\www\folder\index.php on line 39
<?php
set_time_limit(0);
ini_set('default_socket_timeout', 300);
session_start();
/*API*/
define("clientID", '#########################');
define("clientSecret", '#########################');
define("redirectURI", 'http://localhost/folder/index.php');
if(isset($_GET['code'])){
$code = $_GET['code'];
$url = "https://api.instagram.com/oauth/access_token";
$access_token_setting = array
(
'client_id' =>clientID,
'client_secret' =>clientSecret,
'grant_type' => 'autiruzation_code',
'redirect_uri' => redirectURI,
'code' => $code,
);
$curl=curl_init($url);
curl_setopt($curl, CURLOPT_POST,true);
curl_setopt($curl, CURLOPT_POSTFIELDS,$access_token_setting);
//get as string
curl_setopt($curl, CURLOPT_RETURNTRANSFER ,1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER ,false);
$result = curl_exec($curl);
curl_close($curl);
$resutls = json_decode($result,true);
echo $resutls['user']['username'];
}else{ ?> <!DOCTYPE html> <html> <body> <a href="https://api.instagram.com/oauth/authorize/?client_id=<?php echo clientID;?>&redirect_uri=<?php echo redirectURI;?>&response_type=code">log in</a> </body> </html> <?php
}
?>