Advertisement
Guest User

Untitled

a guest
Aug 17th, 2018
658
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.14 KB | None | 0 0
  1. <?php
  2.  
  3. class UserLocationsInfo {
  4. public $username;
  5. public $locations = array();
  6. }
  7.  
  8. set_time_limit(0);
  9. date_default_timezone_set('UTC');
  10.  
  11. require '/Users/emi/Documents/Instagram/vendor/autoload.php';
  12.  
  13. /////// CONFIG ///////
  14. $username = immsilence;
  15. $password = renacikada;
  16. $debug = false;
  17. $truncatedDebug = false;
  18. //////////////////////
  19.  
  20. \InstagramAPI\Instagram::$allowDangerousWebUsageAtMyOwnRisk = true;
  21. $ig = new \InstagramAPI\Instagram($debug, $truncatedDebug);
  22.  
  23. try {
  24. $ig->login($username, $password);
  25. } catch (\Exception $e) {
  26. echo 'Something went wrong: '.$e->getMessage()."\n";
  27. exit(0);
  28. }
  29.  
  30. function getUsernameAndLocationsById($ig, $u_id) {
  31. $reel = $ig->story->getUserStoryFeed($u_id)->getReel();
  32.  
  33. //Check
  34. $found_locations = false;
  35. foreach ($reel->getItems() as $story) {
  36. foreach ($story->getStoryLocations() as $story_location) {
  37. $location = $story_location->getLocation();
  38. if(!is_null($location)) {
  39. $found_locations = true;
  40. break;
  41. }
  42. }
  43. if($found_locations) {
  44. break;
  45. }
  46. }
  47.  
  48. //Print
  49. if($found_locations) {
  50. $info = new UserLocationsInfo();
  51. $info->username = $reel->getUser()->getUsername();
  52. foreach ($reel->getItems() as $story) {
  53. foreach ($story->getStoryLocations() as $story_location) {
  54. $location = $story_location->getLocation();
  55. //echo "\t(".$location->getLng()." ".$location->getLat().")";
  56. array_push($info->locations, $location);
  57. }
  58. }
  59. return $info;
  60. } else {
  61. return null;
  62. }
  63. }
  64.  
  65. function get_users($ig) {
  66. $tray_array = $ig->story->getReelsTrayFeed()->getTray();
  67. $users = array();
  68. foreach ($tray_array as $tray) {
  69. array_push($users, $tray->getUser()->getPk());
  70. }
  71. return $users;
  72. }
  73.  
  74. ?>
  75. <!DOCTYPE html>
  76. <html>
  77. <head>
  78. <title>Instagram mapper</title>
  79. <link rel="stylesheet" type="text/css" href="style.css">
  80. </head>
  81. <body>
  82. <div id="map"></div>
  83. </body>
  84. <script type="text/javascript">
  85. function initMap() {
  86. const size = new google.maps.Size(50, 50);
  87. const icons = [
  88. <?php
  89. for($i = 0; $i < 20; $i++) {
  90. echo "{url: 'https://pp.userapi.com/c841038/v841038611/13b19/_NBajGFom_8.jpg?ava=1', scaledSize: size },";
  91. }
  92. echo "{url: 'https://pp.userapi.com/c841038/v841038611/13b19/_NBajGFom_8.jpg?ava=1', scaledSize: size }";
  93. ?>
  94. ];
  95.  
  96. const places = [
  97.  
  98. <?php
  99. try {
  100. $users = get_users($ig);
  101. foreach ($users as $user) {
  102. $info = getUsernameAndLocationsById($ig, $user);
  103. for($i = 0; $i < count($info->locations) - 1; $i++) {
  104. $location = $info->locations[$i];
  105. echo '{lat:'.$location->getLat().', lng: '.$location->getLng().'},';
  106. }
  107. $location = $info->locations[count($info->locations) - 1];
  108. //echo '{lat:'.$location->getLat().', lng: '.$location->getLng().'}';
  109. usleep(100 * 400);
  110. }
  111. } catch (\Exception $e) {
  112. //echo 'Something went wrong: '.$e->getMessage()."\n";
  113. }
  114. ?>
  115. /*{lat: 59.917727, lng: 30.363933},
  116. {lat: 59.907727, lng: 30.343933},
  117. {lat: 59.927727, lng: 30.343933},
  118. {lat: 59.917727, lng: 30.323933},
  119. {lat: 59.927727, lng: 30.323933}*/
  120. ];
  121.  
  122. const map = new google.maps.Map(
  123. document.getElementById('map'),
  124. {zoom: 14, center: {lat: 59.917727, lng: 30.363933}}
  125. );
  126.  
  127. // Create markers.
  128. for (var i = 0; i < places.length; i++) {
  129. var marker = new google.maps.Marker({
  130. position: places[i],
  131. icon: icons[i],
  132. map: map,
  133. });
  134. marker.addListener('click', function() {
  135. alert("Clicked");
  136. });
  137. }
  138. }
  139. </script>
  140. <script async defer
  141. src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBEa7ZIoHFOXCoPP-_IibPExglZY72D3Pw&callback=initMap">
  142. </script>
  143. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement