function get_instagram() { function getInstaID($username) { $username = strtolower($username); // sanitization $token = "192962714.ab103e5.9b138037d9ed42988e06160bfca32d49"; $url = "https://api.instagram.com/v1/users/search?q=" . $username . "&access_token=" . $token; $get = file_get_contents($url); $json = json_decode($get); foreach ($json->data as $user) { if ($user->username == $username) { return $user->id; } } return '00000000'; // return this if nothing is found } // echo ; function fetchData($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 20); $result = curl_exec($ch); curl_close($ch); return $result; } $result = fetchData("https://api.instagram.com/v1/users/" . getInstaID('moustafahamwi') . "/media/recent/?access_token=192962714.ab103e5.9b138037d9ed42988e06160bfca32d49&count=8"); $result = json_decode($result); foreach ($result->data as $post) { $out = '<div class="instImage">'; $out .= '<a class="group" target="_blank" href="' . $post->link . '">'; $out .= '<img src="' . $post->images->thumbnail->url . '"/>'; $out .= '</a>'; $out .= '</div>'; echo $out; } }
<?php session_start(); set_time_limit(300); require 'init.php'; $out = array(); if (isset($_GET['username'])) { $userid = getInstaID($_GET['username']); $userdata = $instagram->getUserMedia($userid, 10); if (isset($_GET['page'])) { for ($i = 0; $i < $_GET['page']; $i++) { $userdata = $instagram->pagination($userdata, 10); } } $fotky = $userdata->data; foreach ($fotky as $value) { $likes_fotky = $instagram->getMediaLikes($value->id); foreach ($likes_fotky->data as $likes) { //1) lajker->autor $out["lajker->autor"][] = $likes->username . "@" . $_GET['username'] . "@" . $value->id; $lajker[$value->id][] = $likes->username; } $komenty_fotky = $instagram->getMediaComments($value->id); foreach ($komenty_fotky->data as $comments) { //2) komentator->autor $out["komentator->autor"][] = $comments->from->username . "@" . $_GET['username'] . "@" . $value->id; $komentator[$value->id][] = $comments->from->username; $mentions_fotka_komentar = najdiMention($comments->text); if ($mentions_fotka_komentar) { foreach ($mentions_fotka_komentar as $m_f_k) { //6) autor komentare->mention
<?php session_start(); set_time_limit(300); require 'init.php'; $sql = mysql_query("SELECT * FROM wp_instaapi_userdata WHERE instagram_id='' AND existuje=1 limit 0,30"); while ($data = mysql_fetch_assoc($sql)) { $userid = getInstaID($data['username']); if ($userid != "00000000") { $userdata = $instagram->getUser($userid); $out = $userdata->data; if (!$out->id) { neexistujeUser($data['username']); } ulozUserdata($data['username'], $out->id, $out->counts->followed_by, $out->counts->follows, $out->counts->media, $out->bio, $out->website, $out->full_name, $out->profile_picture); } else { neexistujeUser($data['username']); } } if (mysql_num_rows($sql) == 0) { header('Location: index.php?ok=1'); } if (!isset($_GET['page'])) { $page = 1; } else { $page = $_GET['page'] + 1; } if ($page < 10) { header('Location: zpracuj-uzivatele.php?page=' . $page); } else { header('Location: index.php?ok=1');