PHP code example of andreyco / instagram

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

    

andreyco / instagram example snippets



    ram = new Andreyco\Instagram\Client(array(
      'apiKey'      => 'YOUR_APP_KEY',
      'apiSecret'   => 'YOUR_APP_SECRET',
      'apiCallback' => 'YOUR_APP_CALLBACK',
      'scope'       => array('basic'),
    ));

    echo "<a href='{$instagram->getLoginUrl()}'>Login with Instagram</a>";

'providers' => array(
    // ...
    Andreyco\Instagram\Support\Laravel\ServiceProvider\Instagram::class,
    // ...
),

'aliases' => array(
    // ...
    'Instagram' => Andreyco\Instagram\Support\Laravel\Facade\Instagram::class,
    // ...
),

// Pushlish configuration file.
php artisan vendor:publish --provider="Andreyco\Instagram\Support\Laravel\ServiceProvider\Instagram"

// Edit previously created `config/instagram.php` file
return [
    'clientId'     => '...',
    'clientSecret' => '...',
    'redirectUri'  => '...',
    'scope'        => ['basic'],
]

Instagram::getLoginUrl();

$instagram = new Andreyco\Instagram\Client($config);
$instagram->getLoginUrl()


    // Generate and redirect to login URL.
    $url = Instagram::getLoginUrl();

    // After allowing to access your profile, grab authorization *code* when redirected back to your page.
    $code = $_GET['code'];
    $data = Instagram::getOAuthToken($code);

    // Now, you have access to authentication token and user profile
    echo 'Your username is: ' . $data->user->username;
    echo 'Your access token is: ' . $data->access_token;


    // Set user access token
    Instagram::setAccessToken($accessToken);

    // Get all user likes
    $likes = Instagram::getUserLikes();

    // Take a look at the API response
    echo '<pre>';
    print_r($likes);
    echo '<pre>';

new Instagram([
    'apiKey'      => 'YOUR_APP_KEY',
    'apiSecret'   => 'YOUR_APP_SECRET',
    'apiCallback' => 'YOUR_APP_CALLBACK'
]);

new Instagram('YOUR_APP_KEY');

getLoginUrl(['basic', 'likes'], 'uMFYKG5u6v');


    // Follow the user with the ID 1574083
    $instagram->modifyRelationship('follow', 1574083);

$instagram->setEnforceSignedRequests(true);


    $photos = $instagram->getTagMedia('kitten');

    $result = $instagram->pagination($photos);