PHP code example of dulabs / instagram

1. Go to this page and download the library: Download dulabs/instagram library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dulabs / instagram example snippets

 

use Dulabs\Instagram\OAuthManager as OAuth;

$config['api_key'] = "";
$config['api_secret'] = "";
$config['callback_url'] = "http://localhost/instagram/demo/callback.php";
$config['response_type'] = OAuth::RESPONSE_TYPE_CODE;

$oauth = new OAuth();

// initialiaze config
$oauth->setConfig($config);

// define scopes
$loginurl = $oauth->login(['basic','public_content','follower_list']);

header("location: ".$loginurl);



use Dulabs\Instagram\OAuthManager as OAuth;

$config['api_key'] = "";
$config['api_secret'] = "";
$config['callback_url'] = "http://localhost/instagram/callback.php";
$config['response_type'] = OAuth::RESPONSE_TYPE_CODE;

// We need to configure OAuth
$oauth = new OAuth();
$oauth->setConfig($config);

if(isset($_GET['code']) && !empty($_GET['code']))
{
	$token = $oauth->getAccessToken();
	setcookie("instagram_token",$token,time()+3600);
	header("location: demo.php");
}