PHP Classes

PHP Instagram Photo Downloader: Get images uploaded to Instagram using its API

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 227 All time: 8,187 This week: 48Up
Version License PHP version Categories
instagram-downloader 1.0.0BSD License5PHP 5, Graphics, Web services, Social...
Description 

Author

This package can get images uploaded to Instagram using its API.

It can sent HTTP requests to obtain an OAuth token to access Instagram API.

The package can send API requests to get the images from a given user or filtered by hashtags.

Picture of Satish Kumar
  Performance   Level  
Name: Satish Kumar <contact>
Classes: 6 packages by
Country: Australia Australia
Age: 45
All time rank: 2093 in Australia Australia
Week rank: 216 Down3 in Australia Australia Equal
Innovation award
Innovation award
Nominee: 3x

Winner: 2x

Example

<?php
//AUTHOR : SATISH KUMAR
//DATE : 09 DEC 2017
//COMPANY : SLAB TECHSOL SYSTEM
//EMAIL : info@techsolsystem.com
//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) );
}

?>


Details

Instagram API Wrapper class will help to create a base wrapper class for Instagram API request/response with OAuth. You have to register yourself as developer at the Instagram Developer Platform and set up an App. Then use the credentials generated from the Instagram developer account in the wrapper class to call two class functions. This class aims at handshaking with instagram by authenticating user (OAuth2) and then perform below functionalities. 1. Get images uploaded by instagram username 2. Get images uploaded based on the hashtags usage: //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) ); }

  Files folder image Files (3)  
File Role Description
Plain text file class.instagram_api_wrapper.php Class Instagram API Wrapper
Accessible without login Plain text file index.php Example Instagram API usage example
Accessible without login Plain text file readme.txt Doc. read me

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:227
This week:0
All time:8,187
This week:48Up