Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // API mail.ru
- <?php
- $id = "ID";
- $password = "PASSWORD";
- $url = "http://top.mail.ru/json/srchlanding?id=$id&action=json&password=$password&pp=50000&rettype=all";
- $data = json_decode(file_get_contents($url));
- $domains = [];
- $se = [];
- foreach($data->elements as $hit):
- $domains[$hit->sign][parse_url($hit->url, PHP_URL_HOST)] += $hit->hits;
- $se[$hit->sign] += $hit->hits;
- endforeach;
- foreach($se as $name => $value):
- echo "<h2>$name = $value</h2>";
- echo "<table>";
- foreach($domains[$name] as $domain => $hits):
- echo "<tr><td><i>$domain</i></td><td><b>$hits</b></td></tr>";
- endforeach;
- echo "</table>";
- endforeach;
- ?>
- // API mail.ru
- // API mail.ru - навигация по дням в стиле «туда-сюда»
- <?php
- $id = "ID";
- $password = "PASSWORD";
- $offset = isset($_GET['day']) ? $_GET['day'] : 0;
- $date = date('Y-m-d', time() - $offset * 24 * 60 * 60);
- $yesterday = date('Y-m-d', time() - ($offset + 1) * 24 * 60 * 60);
- $tomorrow = date('Y-m-d', time() - ($offset - 1) * 24 * 60 * 60);
- $url = "http://top.mail.ru/json/srchlanding?id=$id&action=json&password=$password&pp=50000&rettype=all&date=$date";
- $data = json_decode(file_get_contents($url));
- $domains = [];
- $se = [];
- foreach ($data->elements as $hit):
- $domains[$hit->sign][parse_url($hit->url, PHP_URL_HOST)] += $hit->hits;
- $se[$hit->sign] += $hit->hits;
- endforeach;
- echo "<h1>Дата: $date Всего: " . array_sum($se) . "</h1>";
- echo "<div><a href='?day=" . ($offset + 1) . "'>$yesterday</a>";
- if ($offset):
- echo " <a href='?day=" . ($offset - 1) . "'>$tomorrow</a>";
- endif;
- echo "</div>";
- foreach ($se as $name => $value):
- echo "<div style='float:left; margin-right: 1em; padding: 0 1em; border: 1px solid black;'><h2>$name: $value</h2>";
- echo "<table>";
- foreach ($domains[$name] as $domain => $hits):
- echo "<tr><td><i>$domain</i></td><td><b>$hits</b></td></tr>";
- endforeach;
- echo "</table></div>";
- endforeach;
- ?>
- // API mail.ru - навигация по дням в стиле «туда-сюда»
Advertisement
Add Comment
Please, Sign In to add comment