function sendgrid_sga_data_api() { header("Content-Type: application/json"); if ($_POST['api_key'] != get_option("sendgrid_sga_apikey")) { $output = array("error" => true, "message" => "Unauthenticated."); echo json_encode($output); die; } $period_start = create_start_time($_POST['period_start'], true); $period_end = create_end_time($_POST['period_end'], true); create_table($period_start, $period_end); $output = array("error" => true, "message" => "Unknown error."); $body = array(); if ($_POST['data'] == "users") { $top_users = get_top_users(); foreach ($top_users as $rank => $user_info) { $formatted_user_info = format_user_info($user_info); $body[] = array("raw" => array("post_author" => get_post_author($user_info->post_author), "mantime" => (int) $user_info->mantime, "visits" => (int) $user_info->visits, "pageviews" => (int) $user_info->pageviews, "avg_time_on_page" => (double) $user_info->avg_time_on_page, "entrance_rate" => (double) $user_info->entrance_rate, "exit_rate" => (double) $user_info->exit_rate), "formatted" => $formatted_user_info); } $output = array("error" => false, "body" => $body, "period_start" => $period_start, "period_end" => $period_end); } elseif ($_POST['data'] == "posts") { $top_posts = get_top_posts(); foreach ($top_posts as $rank => $post_info) { $formatted_post_info = format_post_info($post_info); $body[] = array("raw" => array("guid" => $post_info->guid, "post_title" => $post_info->post_title, "post_author" => get_post_author($post_info->post_author), "mantime" => (int) $post_info->mantime, "visits" => (int) $post_info->visits, "pageviews" => (int) $post_info->pageviews, "avg_time_on_page" => (double) $post_info->avg_time_on_page, "entrance_rate" => (double) $post_info->entrance_rate, "exit_rate" => (double) $post_info->exit_rate), "formatted" => $formatted_post_info); } $output = array("error" => false, "body" => $body, "period_start" => $period_start, "period_end" => $period_end); } else { $output = array("error" => true, "message" => "Data attribute not understood, please provide either users or posts"); } echo json_encode($output); die; }
?> </h4> </div> </div> <!-- /well --> <div class="brown-style"> <h4 class="center"><?php echo $lib_blogs_20; ?> </h4> <div class="row" style="font-size:100%;"> <div class="col-lg-12"> <ul class="list-unstyled center"> <li><i class="glyphicon glyphicon-user" style="font-size:250%;"></i></li> <?php $top_users = get_top_users(); foreach ($top_users as $user) { ?> <li><a href="blogs.php?user_id=<?php echo $user['b_post_user_id']; ?> "><?php echo $user['login']; ?> (<?php echo $user['rate']; ?> )</a></li> <?php } ?>
ini_set("max_execution_time", 123456); $instagram = new Instagram("af797da93a514a9381d6862490944f45"); $tag = "video"; // Set number of photos to show $limit = 10; $result = $instagram->getTagMedia($tag, $limit); // Users $users = get_users_post_like($result->data); echo "Users (" . sizeof($users) . ")<br>"; echo "Username Posts Likes<br>"; foreach ($users as $user) { echo $user["user_id"] . "--" . $user["username"] . "--" . $user["post_num"] . "--" . $user["like_num"] . "<br>"; } echo "<br><br>Top Users<br>"; // Search user with most posts and likes $top_users = get_top_users($instagram, $users); $max_post_idx = $top_users["max_post_idx"]; $max_like_idx = $top_users["max_like_idx"]; $max_post = $users[$max_post_idx]["post_num"]; $max_like = $users[$max_like_idx]["like_num"]; $max_post_username = $users[$max_post_idx]["username"]; $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 {