Віджет інстаграм

Основна комп’ютер соціальна мережа 842

Апгр. 3-2018: більше не працює, інстаграм змінив АПІ.

Знайшов старенький код на гітхубі і троха його добидлокодив)  В якості прикладу -- профіль однієї з улюблених суїцид-баб (до речі, українка). Виводе до 12 останніх фото з кількістю коментарів та лайків. 

Завантажити без реєстрації та смс)

<link rel="stylesheet" href="http://css.levus.info/css/levus-3.0.css" />
<style>
#ins .post{ position:relative;}
#ins .post a{ font-size: 18px;}
#ins .post a p{ position: absolute; top: 40%; left: 0; width: 100%; z-index: 2; text-align: center;}
#ins .post a img{ width:100%; height:auto; opacity: 1; -webkit-transition: all 0.5s; transition: all 0.5s;}

#ins .post a p span{ color: rgba(255,255,255,0); -webkit-transition: all 2s; transition: all 2s; padding: 0 5px;}
#ins .post a:hover p span{ color: rgba(255,255,255,1);}
#ins .post a:hover img{ opacity: 0.6;}
</style>
<?php
function scrape_ins($username) {
$ins_source = file_get_contents('http://instagram.com/'.$username);
$shards = explode('window._sharedData = ', $ins_source);
$ins_json = explode(';</script>', $shards[1]);
$ins_array = json_decode($ins_json[0], TRUE);
return $ins_array;
}

// назва профіля інстаграм
$my_account = 'liya_suicide';

$results_array = scrape_ins($my_account);

// кількість фотографій (максимально 12)
$counter = 12;

echo '<div class="li4" id="ins">';
for($i = 0; $i < $counter; $i++){

$latest_array = $results_array['entry_data']['ProfilePage'][0]['user']['media']['nodes'][$i];
echo '
<div class="post">
<a href="http://instagram.com/p/'.$latest_array['code'].'">
<p>
<span>Like: ' . $latest_array['likes']['count'] . '</span>
<span>Comment: ' . $latest_array['comments']['count'] . '</span>
</p>
<img src="'.$latest_array['thumbnail_src'].'">
</a>
</div>';
}
echo '</div>';

?>

Додаткові опції:

<?php

// followed_by
echo 'Кількість фоловерів: ' . $results_array['entry_data']['ProfilePage'][0]['user']['followed_by']['count'];

// bio
echo 'Біографія' . $results_array['entry_data']['ProfilePage'][0]['user']['biography'];

// follows
echo 'Cтежать: ' . $results_array['entry_data']['ProfilePage'][0]['user']['follows']['count'];

// full name
echo 'Повне ім’я: ' . $results_array['entry_data']['ProfilePage'][0]['user']['full_name'];

// profile pic url
echo 'Картинка профіля: <img src="' . $results_array['entry_data']['ProfilePage'][0]['user']['profile_pic_url'] . '" alt=""/>';

// followed by
echo 'Читачів: ' . $results_array['entry_data']['ProfilePage'][0]['user']['followed_by']['count'];

// count
echo 'Дописів: ' . $results_array['entry_data']['ProfilePage'][0]['user']['media']['count'];
?>

Демосторінка інстаграм-віджету