<?php 
//AUTHOR : SATISH KUMAR 
//DATE : 09 DEC 2017 
//COMPANY : SLAB TECHSOL SYSTEM 
//EMAIL : [email protected] 
//WEBSITE: www.techsolsystem.com 
 
 
//include instagram wrapper class 
include "class.instagram_api_wrapper.php"; 
//Initialize the class 
//create object of the main class 
$obj=new instagram_api_wrapper(); 
 
//assign values to the Instagram clientid, secret, and redirect url 
$obj->client_id='YOUR INSTAGRAM CLIENT ID'; 
$obj->secret='YOUR INSTAGRAM SECRET KEY'; 
$obj->redirect_url='YOUR APPLICATION REDIRECT URL'; 
 
//set media for the username - media will be returned for the username 
//in case of SANDBOX ACCOUNT USE YOUR USERNAME 
$search_by_username = 'USERNAME_YOU WISH TO SEARCH'; 
 
//set media for the hashtag - media will be returned for the hashtag 
$search_by_tag ='business'; 
 
//Authenticate user (OAuth2) 
//First step to get all the media file is to handshake with Instagram API - returns code 
if(!isset($_REQUEST['code'])){ 
    $obj->getInstagramCode($obj->client_id,$obj->redirect_url); 
} 
 
//once code is returned - authroise the API to get Token -this token will be used throughout the API request/response 
if(isset($_REQUEST['code'])){ 
    $code = $_REQUEST['code']; 
     
     
    //get token from Instagram 
    $access_token = $obj->authorizeAPI($code,$obj->client_id,$obj->secret,$obj->redirect_url); 
     
     
    //using token search media by username 
    echo '<br>Search by Username<br>'; 
    print_r($obj->getInstagramMediaByUsername($search_by_username,$access_token)); 
     
     
    //using token search media by hashtag 
    echo '<br>Search by Hashtag<br>'; 
    print_r( $obj->getInstagramImagesByTag($search_by_tag,$access_token) ); 
} 
 
?>
 
 |