Instagram – Get Access Token and User Profile

  1. The first – Create your Client for Instagram
Create client
Client details

2. Next step – add redirect url for Client

3. Create API on your localhost
Create 2 files: index.php and response.php

File index.php

$clientId = 'YOUR_CLIENT_ID';
$redirectUri = 'http://localhost/instagram/response.php';
$url = "{$clientId}&redirect_uri={$redirectUri}&response_type=code";

File response.php

$clientId = 'YOUR_CLIENT_ID';
$clientSecret = 'YOUR_CLIENT_SECRET';
$redirectUri = 'http://localhost/instagram/response.php';
$code = $_GET['code'];
$url = "";
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$server_output = curl_exec($ch);
$server_output = json_decode($server_output);
curl_close ($ch);

The last: go to your browser and type: http://localhost/instagram

About the Author: admin

Leave a Reply

Your email address will not be published. Required fields are marked *