пример
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<?$token = 'TOKEN!!!'; $user_id = 'self'; $instagram_cnct = curl_init(); curl_setopt( $instagram_cnct, CURLOPT_URL, "https://api.instagram.com/v1/users/" . $user_id . "/media/recent?access_token=" . $token ); curl_setopt( $instagram_cnct, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt( $instagram_cnct, CURLOPT_TIMEOUT, 15 ); $media = json_decode( curl_exec( $instagram_cnct ) ); curl_close( $instagram_cnct ); $limit = 20; $size = 262; foreach(array_slice($media->data, 0, $limit) as $data): if ($data->type != 'video' && empty($data->videos)):?> <li class="insta-tape__item"> <a href="<?=$data->link?>" class="insta-tape__link" style="background-image: url(<?=$data->images->low_resolution->url?>);" target="_blank"> <p class="likes"><img src="<?=SITE_TEMPLATE_PATH?>/img/like.png"> <span><?=$data->likes->count?></span></p> <p class="comments"><img src="<?=SITE_TEMPLATE_PATH?>/img/comment.png"> <span><?=$data->comments->count?></span></p> </a> </li> <?endif; endforeach;?> |
Получить токен можно по ссылке в гет запросе
1 |
https://api.instagram.com/oauth/authorize/?client_id=ID приложения&redirect_uri=URL-адрес&response_type=token |