Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.01 KB | None | 0 0
  1.     $userid = ''; // userid
  2.             $token  = '';   // token access
  3.             $count  = ''; // wie viele auslesen
  4.  
  5.  
  6.               function fetchData($url){
  7.               $ch = curl_init();
  8.               curl_setopt($ch, CURLOPT_URL, $url);
  9.               curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  10.               curl_setopt($ch, CURLOPT_TIMEOUT, 20);
  11.               $result = curl_exec($ch);
  12.               curl_close($ch);
  13.               return $result;
  14.               }
  15.  
  16.               $result = fetchData("https://api.instagram.com/v1/users/$userid/media/recent/?access_token=$token&count=$count");
  17.  
  18.  
  19.               $result = json_decode($result);
  20.  
  21.               if(isset($result))
  22.               {
  23.                     foreach ($result->data as $post) {
  24.                  if(empty($post->images->low_resolution->url)) {
  25.                    // Do Nothing
  26.                  }
  27.                  else {
  28.  
  29.                  
  30.                    
  31.  
  32.                     ?>
  33.  
  34.  
  35.                    
  36.                   <img src="<?php echo
  37.                         $post->images->low_resolution->url ?>" alt="<?php echo $post->caption->text
  38.                         ?>"/>
  39.                     <?php
  40.                  }
  41.  
  42.               }
  43.           }else{
  44.             echo "Die User ID oder der Token ist Falsch!";
  45.           }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement