Всем привет, помогите
Заказчик попросил настроить ленту instagramm на сайте. Просто поменять новый api, но по каким-то причинам у меня не выходи этого сделать. Попросил его зарегаться через :
https://developers.facebook.com и сделать все по инструкции, которую я ему скинул. Он мне перекинул код, который ему дал сам facebook, я так понял это и был api, но он почему-то не работает в коде. Вот код:
<?php
class Instagram {
static function get_gallery($params = array()) {
$access_token = htmlentities('IGQVJXbTV0eXJfQ3o4cWswak9SYlhPTmo5bVRIR3B2TkZACT1owdlVYMFFDeHlPMXQzdFozZA3RUek04dVJ0NUh4M09DRFBOZA1hpUXVYQ1pFM1hPeXY1dmhGVjNuTXpkSEc1b19FMlRCWTdXVzF2NzJmUgZDZD');
$unique_str = htmlentities('d4b3e776394f9c');
$theme_url = get_template_directory();
$cache_dir = $theme_url.'/'.htmlentities('/cache_instagram');
$filename = $cache_dir.'/'.date('Ymd').'_'.$unique_str;
$output = '';
$output2 = '';
if (file_exists($filename)) {
// Если есть файл в кеше - считываем
$insta_json = file_get_contents($filename);
$insta_array = json_decode($insta_json, true);
} else {
// В противном случае - очищаем папку кеша
$oldfiles = scandir($cache_dir);
foreach ($oldfiles as $oldfile) {
if ($oldfile != '.' && $oldfile != '..' && $oldfile != 'index.php') {
unlink($cache_dir.'/'.$oldfile);
}
}
reset($oldfiles);
// Затем получаем новый JSON
$insta_json = file_get_contents('
https://api.instagram.com/v1/users/self/media/recent?access_token='.$access_token);
$insta_array = json_decode($insta_json, true);
// И записываем его в файл
$fp = fopen($filename, 'w');
fwrite($fp, $insta_json);
fclose($fp);
};
if (isset($insta_array['data'])) {
$output .= '<div class="instagram-feed">';
$output .= '<div class="instagram-posts">';
$output .= '<div class="owl-carousel">';
foreach($insta_array['data'] as $instagram_post) {
$post_id = $instagram_post['id'];
$post_thumb = $instagram_post['images']['standard_resolution']['url'];
$post_type = $instagram_post['type'];
$post_link = $instagram_post['link'];
$post_likes = $instagram_post['likes']['count'];
$post_comments = $instagram_post['comments']['count'];
$post_caption = $instagram_post['caption'];
$post_caption_from = $instagram_post['caption']['from']['username'];
$post_caption_text = $instagram_post['caption']['text'];
$profile_full_name = $instagram_post['user']['full_name'];
$profile_picture = $instagram_post['user']['profile_picture'];
$profile_username = $instagram_post['user']['username'];
$post_caption_text_f = '';
$post_caption_text = str_replace('#', ' #', $post_caption_text);
$post_caption_text_a = explode(' ', $post_caption_text);
foreach ($post_caption_text_a as $pctpart) {
if ($pctpart) {
if ($pctpart[0] == '#') {
$pctpart = '<a href="
https://www.instagram.com/explore/tags/'.rawurlencode(substr($pctpart, 1)).'/" class="instagram-tag" target="_blank">'.$pctpart.'</a> ';
};
$post_caption_text_f .= $pctpart.' ';
};
};
$output .= '<div class="instagram-post">';
$output .= '<div class="instagram-post-inner" style="background-image: url('.$post_thumb.')">';
$output .= '<div class="instagram-type type-'.$post_type.'"></div>';
$output .= '<a href="#" rel="nofollow" class="instagram-post-hover-info js-instagram-post-open" data-id="#instagram_post_'.$post_id.'">';
$output .= '<div><span>'.$post_likes.'</span> <span>'.$post_comments.'</span></div>';
$output .= '</a>';
$output .= '</div>';
$output .= '</div>';
$output2 .= '<div class="instagram-popup" id="instagram_post_'.$post_id.'">';
$output2 .= '<div class="instagram-popup-inner">';
if ($post_type == 'carousel') {
if ($instagram_post['carousel_media']) {
$output2 .= ' <div class="instagram-popup-media instagram-popup-media-carousel">';
$carousel_count = 0;
foreach ($instagram_post['carousel_media'] as
$carousel_im