Advertisement
syabani

API Instagram PHP

Dec 11th, 2019
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. <?php
  2.  
  3.   function getCurl($url) {
  4.    
  5.     $curl = curl_init();
  6.     curl_setopt($curl, CURLOPT_URL, $url);
  7.     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  8.     $result = curl_exec($curl);
  9.     curl_close($curl);
  10.  
  11.     return json_decode($result, true);
  12.   }
  13.  
  14.   // Instagram API
  15.   $accessToken = 'xxx';
  16.   $result = getCurl('https://api.instagram.com/v1/users/self?access_token=xxx');
  17.   $usernameIG = $result['data']['username'];
  18.   $profilePic = $result['data']['profile_picture'];
  19.   $followersIG = $result['data']['counts']['followed_by'];
  20.  
  21.   // Latest IG Post API
  22.   $result = getCurl('http://api.instagram.com/v1/users/self/media/recent/?access_token=xxx=5');
  23.   var_dump($result);
  24.  
  25.   // $photos = [];
  26.   // foreach ($result['data'] as $photo) {
  27.   //   $photos[] = $photo['images']['thumbnail']['url'];
  28.   // }
  29.  
  30.   // var_dump($result);
  31.  
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement