Advertisement
Guest User

Untitled

a guest
Jan 24th, 2019
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.18 KB | None | 0 0
  1. <?php
  2. function scrape_insta_user_images($username) {
  3.     $insta_source = file_get_contents('https://www.instagram.com/'.$username.'/'); // instagram user url
  4.     $shards = explode('window._sharedData = ', $insta_source);
  5.     $insta_json = explode(';</script>', $shards[1]);
  6.     $insta_array = json_decode($insta_json[0], TRUE);
  7.     return $insta_array;
  8. }
  9. $username = 'sebuahnasehat'; // username bro
  10. $results_array = scrape_insta_user_images($username);
  11.  
  12. $limit = 6; // foto yang mau ditampilkan
  13. $image_array= array(); // array to store images.
  14.     for ($i=0; $i < $limit; $i++) {    
  15.         //Get images from json  
  16.         if(isset($results_array['entry_data']['ProfilePage'][0]['graphql']['user']['edge_owner_to_timeline_media']['edges'][$i])){
  17.             $latest_array = $results_array['entry_data']['ProfilePage'][0]['graphql']['user']['edge_owner_to_timeline_media']['edges'][$i]['node'];
  18.             $image_data  =$latest_array['thumbnail_src']; // thumbnail Gambar
  19.             //$image_data  = '<img src="'.$latest_array['display_src'].'">'; Kualitas Standar
  20.             array_push($image_array, $image_data);
  21.         }
  22.     }
  23.     foreach ($image_array as $image) {
  24.    $text=$image;
  25. echo'<pre>';
  26.                 print_r($text2);
  27.     }
  28.            
  29.           ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement