I am trying to get number of total followers that followed me in Instagram. Unfortunately not a single solution is working for me. After a long research only this one is working in my case. I am going to share code may be it will help someone else.
First you have to register your application at instagr.am/developer
Demo | Download
Download Link-2
First you have to register your application at instagr.am/developer
Demo | Download
Download Link-2
require 'instagram.class.php';
require 'instagram.config.php';
// Receive OAuth code parameter
$code = $_GET['code'];
// Check whether the user has granted access
if (true === isset($code)) {
$data = $instagram->getOAuthToken($code);
if(empty($data->user->username))
{
header('Location: index.php');
}
else
{
session_start();
$_SESSION['userdetails']=$data;
$url = 'https://api.instagram.com/v1/users/'.$data->user->id.'?access_token='.$data->access_token;
$api_response = file_get_contents($url);
$record = json_decode($api_response);
echo $user=$data->user->username."<br>";
echo $fullname=$data->user->full_name."<br>";
echo $bio=$data->user->bio."<br>";
echo $website=$data->user->website."<br>";
echo $id=$data->user->id."<br>";
echo $token=$data->access_token."<br>";
echo $followed_by = $record->data->counts->followed_by."<br>";
}
}
else
{
// Check whether an error occurred
if(true === isset($_GET['error']))
{
echo 'An error occurred: '.$_GET['error_description'];
}
}
