Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class UserLocationsInfo {
- public $username;
- public $locations = array();
- }
- set_time_limit(0);
- date_default_timezone_set('UTC');
- require '/Users/emi/Documents/Instagram/vendor/autoload.php';
- /////// CONFIG ///////
- $username = immsilence;
- $password = renacikada;
- $debug = false;
- $truncatedDebug = false;
- //////////////////////
- \InstagramAPI\Instagram::$allowDangerousWebUsageAtMyOwnRisk = true;
- $ig = new \InstagramAPI\Instagram($debug, $truncatedDebug);
- try {
- $ig->login($username, $password);
- } catch (\Exception $e) {
- echo 'Something went wrong: '.$e->getMessage()."\n";
- exit(0);
- }
- function getUsernameAndLocationsById($ig, $u_id) {
- $reel = $ig->story->getUserStoryFeed($u_id)->getReel();
- //Check
- $found_locations = false;
- foreach ($reel->getItems() as $story) {
- foreach ($story->getStoryLocations() as $story_location) {
- $location = $story_location->getLocation();
- if(!is_null($location)) {
- $found_locations = true;
- break;
- }
- }
- if($found_locations) {
- break;
- }
- }
- //Print
- if($found_locations) {
- $info = new UserLocationsInfo();
- $info->username = $reel->getUser()->getUsername();
- foreach ($reel->getItems() as $story) {
- foreach ($story->getStoryLocations() as $story_location) {
- $location = $story_location->getLocation();
- //echo "\t(".$location->getLng()." ".$location->getLat().")";
- array_push($info->locations, $location);
- }
- }
- return $info;
- } else {
- return null;
- }
- }
- function get_users($ig) {
- $tray_array = $ig->story->getReelsTrayFeed()->getTray();
- $users = array();
- foreach ($tray_array as $tray) {
- array_push($users, $tray->getUser()->getPk());
- }
- return $users;
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>Instagram mapper</title>
- <link rel="stylesheet" type="text/css" href="style.css">
- </head>
- <body>
- <div id="map"></div>
- </body>
- <script type="text/javascript">
- function initMap() {
- const size = new google.maps.Size(50, 50);
- const icons = [
- <?php
- for($i = 0; $i < 20; $i++) {
- echo "{url: 'https://pp.userapi.com/c841038/v841038611/13b19/_NBajGFom_8.jpg?ava=1', scaledSize: size },";
- }
- echo "{url: 'https://pp.userapi.com/c841038/v841038611/13b19/_NBajGFom_8.jpg?ava=1', scaledSize: size }";
- ?>
- ];
- const places = [
- <?php
- try {
- $users = get_users($ig);
- foreach ($users as $user) {
- $info = getUsernameAndLocationsById($ig, $user);
- for($i = 0; $i < count($info->locations) - 1; $i++) {
- $location = $info->locations[$i];
- echo '{lat:'.$location->getLat().', lng: '.$location->getLng().'},';
- }
- $location = $info->locations[count($info->locations) - 1];
- //echo '{lat:'.$location->getLat().', lng: '.$location->getLng().'}';
- usleep(100 * 400);
- }
- } catch (\Exception $e) {
- //echo 'Something went wrong: '.$e->getMessage()."\n";
- }
- ?>
- /*{lat: 59.917727, lng: 30.363933},
- {lat: 59.907727, lng: 30.343933},
- {lat: 59.927727, lng: 30.343933},
- {lat: 59.917727, lng: 30.323933},
- {lat: 59.927727, lng: 30.323933}*/
- ];
- const map = new google.maps.Map(
- document.getElementById('map'),
- {zoom: 14, center: {lat: 59.917727, lng: 30.363933}}
- );
- // Create markers.
- for (var i = 0; i < places.length; i++) {
- var marker = new google.maps.Marker({
- position: places[i],
- icon: icons[i],
- map: map,
- });
- marker.addListener('click', function() {
- alert("Clicked");
- });
- }
- }
- </script>
- <script async defer
- src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBEa7ZIoHFOXCoPP-_IibPExglZY72D3Pw&callback=initMap">
- </script>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement