PHP code example of fantasyrock / instagram

1. Go to this page and download the library: Download fantasyrock/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/ */

    

fantasyrock / instagram example snippets


 

stagram\Adapters\Http\GuzzleAdapter;
use Instagram\Instagram;

$adapter = new GuzzleAdapter('access_token');
$factory = new Instagram($adapter);

 

stagram\Adapters\Storage\NativeSessionAdapter;
use Instagram\Security\Credentials;

$storage     = new NativeSessionAdapter();
$credentials = new Credentials(['client_id', 'client_secret', 'redirect_uri'], $storage);



nstagram\Adapters\Http\GuzzleAdapter;
use Instagram\Adapters\Storage\NativeSessionAdapter;
use Instagram\Security\Credentials;
use Instagram\Instagram;

$storage     = new NativeSessionAdapter();
$credentials = new Credentials([
    'client_id'     => 'YOUR-CLIENT-ID',
    'client_secret' => 'YOUR-CLIENT-SECRET',
    'redirect_uri'  => 'REDIRECT-URI
  ], $storage);

// You may provide additional scope as array of desired additional permissions
$loginUrl = $credentials->getLoginUrl(['basic', 'likes']);

 

stagram\Adapters\Http\GuzzleAdapter;
use Instagram\Adapters\Storage\NativeSessionAdapter;
use Instagram\Security\Credentials;
use Instagram\Instagram;

$storage     = new NativeSessionAdapter();
$credentials = new Credentials([
    'client_id'     => 'YOUR-CLIENT-ID', 
    'client_secret' => 'YOUR-CLIENT-SECRET', 
    'redirect_uri'  => 'REDIRECT-URI
  ], $storage);
  
$adapter = new GuzzleAdapter($credentials->getToken());  
$factory = new Instagram($adapter);
  
  
$user = $factory->userClient();
var_dump($user->getInfo());