Example #1
0
$max_like_username = $users[$max_like_idx]["username"];
echo "Most posts: " . $max_post . " posts by " . $max_post_username . "<br>";
echo "Most likes: " . $max_like . " likes by " . $max_like_username . "<br><br><br>";
// Activities Volume
$image_type_count = 0;
$video_type_count = 0;
foreach ($result->data as $media) {
    if ($media->type === "image") {
        $image_type_count++;
    } else {
        $video_type_count++;
    }
}
echo "Activities Volume<br>" . "Images: " . $image_type_count . "<br>";
echo "Videos: " . $video_type_count . "<br>  ";
$timeinterval = get_time_interval($result->data);
?>

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Instagram - popular photos</title>
  <link href="https://vjs.zencdn.net/4.2/video-js.css" rel="stylesheet">
  <link href="assets/style.css" rel="stylesheet">
  <link href="https://cdnjs.cloudflare.com/ajax/libs/jqcloud/1.0.4/jqcloud.css" rel="stylesheet">
   
</head>
<body>
<div id="wordcloud" style="width: 550px; height: 350px;margin: 0 auto"></div>
<?php

header("content-type:application/json");
require "vendor/cosenary/instagram/src/Instagram.php";
require "radar.php";
use MetzWeb\Instagram\Instagram;
ini_set("max_execution_time", 123456);
$instagram = new Instagram("af797da93a514a9381d6862490944f45");
$hashtag = $_REQUEST["hashtag"];
$limit = 500;
$posts = $instagram->getTagMedia($hashtag, $limit)->data;
$post_left = $limit - count($posts);
$min_tag_id = $posts[count($posts) - 1]->id;
while ($post_left > 0) {
    $posts_temp = $instagram->getTagMediaCont($hashtag, $post_left, $min_tag_id)->data;
    $posts = merge_array_ordered($posts, $posts_temp);
    $post_left -= count($posts_temp);
    $min_tag_id = $posts_temp[count($posts_temp) - 1]->id;
}
$tag_count = get_tag_count($posts, $hashtag);
$word_cloud = convert_tag_count_to_word_array($tag_count);
$top_posts_limit = 5;
$top_posts = get_most_posts($posts, $top_posts_limit);
$users = get_users_post_like($posts);
$top_users = get_top_users($instagram, $users);
$image_video_count = get_image_video_count($posts);
$time_interval = get_time_interval($posts);
$result = array("word_cloud" => $word_cloud, "posts" => $posts, "top_posts" => $top_posts, "users" => $users, "top_users" => $top_users, "type_count" => $image_video_count, "time_interval" => $time_interval);
echo json_encode($result);
exit;