SHARE
TWEET

API Instagram PHP

syabani Dec 11th, 2019 (edited) 101 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top