PHP code example of samsonos / php_instagram

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

    

samsonos / php_instagram example snippets


class InstagramConfig extends \samsonphp\config\Entity
{
    public $appId = 'YOUR_CLIENT_ID';

    public $appSecret = 'YOUR_CLIENT_SECRET';
}

/** @var \samson\instagram\Instagram $instagram Get SamsonPHP Instagram module */
$instagram = m('instagram');

// Define tag
$myTag = 'adventure';

// Get list of posts
$posts = $instagram->listByTag($myTag, array('count' => 10));

/** @var \samson\instagram\Instagram $instagram Get SamsonPHP Instagram module */
$instagram = m('instagram');

// Define media to like
$myMediaID = '657988443280050001_25025320';

// Get list of posts
$posts = $instagram->likeMedia($myMediaID, 'ACCESS_TOKEN');

/** @var \samson\instagram\Instagram $instagram Get SamsonPHP Instagram module */
$instagram = m('instagram');

// Define media to like
$user_id = '12345678';

// Get list of posts
$posts = $instagram->setUserRelationship($user_id, 'ACCESS_TOKEN', 'unfollow');

/** @var \samson\instagram\Instagram $instagram Get SamsonPHP Instagram module */
$instagram = m('instagram');

// Get list of posts
$posts = $instagram->subscribe('user', 'media', 'VERIFY_TOKEN', 'callback-function');