Пример #1
0
<?
$_SERVER["DOCUMENT_ROOT"] = "/home/bitrix/www";
require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");

use MetzWeb\Instagram\Instagram;

require_once 'instagram.class.php';

// Initialize class for public requests
$instagram = new Instagram('384463ff33314dc6a8e0e129d28b5e25');
$clientID = $instagram->getApiKey();
$tag = 'kdmarket2016';

if($_GET['code'] == ''){
    LocalRedirect('https://api.instagram.com/oauth/authorize/?client_id=384463ff33314dc6a8e0e129d28b5e25&redirect_uri=http://kdmarket.ru/promo/instagram/get_all_posts.php&response_type=code');
} else {
    $result = array();
    $code = $instagram->getOAuthToken($_GET['code']);
    echo $_GET['code'];
    $token = $instagram->setAccessToken($code->access_token);

    // Receive AJAX request and create call object
    $media = $instagram->getTagMedia($tag, true);
    $maxID = $media->pagination->next_max_id;


    $i = 0;
    foreach ($media->data as $data) {
        if($data->caption->from->username != "kdmarket"){
            $result[$i]['THUMB'] = $data->images->low_resolution->url;
            $result[$i]['IMAGE'] = $data->images->standard_resolution->url;