Advertisement
lamiastella

PaginationExample.php

Mar 6th, 2017
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.27 KB | None | 0 0
  1.  1 <?php
  2.   2
  3.   3 include __DIR__.'/../vendor/autoload.php';
  4.   4 require '../src/Instagram.php';
  5.   5
  6.   6 /////// CONFIG ///////
  7.   7 $username = 'mona_of_green_gables';
  8.   8 $password = '';
  9.   9 $debug = false;
  10.  10 //////////////////////
  11.  11
  12.  12 // THIS IS AN EXAMPLE OF HOW TO USE NEXT_MAX_ID TO PAGINATE
  13.  13 // IN THIS EXAMPLE, WE ARE RETRIEVING SELF FOLLOWERS
  14.  14 // BUT THE PROCESS IS SIMILAR IN OTHER REQUESTS
  15.  15
  16.  16 $i = new \InstagramAPI\Instagram($debug);
  17.  17
  18.  18 $i->setUser($username, $password);
  19.  19
  20.  20 //$buzzfeed_id = $i->getUsernameId('buzzfeed');
  21.  21 //$mona_id = $i->getUsernameId('mona_of_green_gables');
  22.  22 try {
  23.  23     $i->login();
  24.  24 } catch (Exception $e) {
  25.  25     echo 'something went wrong '.$e->getMessage()."\n";
  26.  26     exit(0);
  27.  27 }
  28.  28 try {
  29.  29     /*
  30.  30     $helper = null;
  31.  31     $followers = [];
  32.  32
  33.  33     do {
  34.  34         if (is_null($helper)) {
  35.  35             $helper = $i->getSelfUserFollowers();
  36.  36         } else {
  37.  37             $helper = $i->getSelfUserFollowers($helper->getNextMaxId());
  38.  38         }
  39.  39
  40.  40         $followers = array_merge($followers, $helper->getUsers());
  41.  41     } while (!is_null($helper->getNextMaxId()));
  42.  42
  43.  43     echo "My followers: \n";
  44.  44     foreach ($followers as $follower) {
  45.  45        # echo '- '.$follower->getUsername()."\n";
  46.  46     }
  47.  47     */
  48.  48     /*
  49.  49     $tag_helper = null;
  50.  50     $tags = [];
  51.  51
  52.  52     do {
  53.  53         if (is_null($tag_helper)) {
  54.  54             $tag_helper = $i->getUserTags(53112486);
  55.  55         } else {
  56.  56             $tag_helper = $i->getUserTags($tag_helper->getNextMaxId());
  57.  57         }
  58.  58         $tags = array_merge($tags, $tag_helper->getUser());
  59.  59     } while (!is_null($tag_helper->getNextMaxId()));
  60.  60
  61.  61     foreach ($tags as $tag){
  62.  62         echo '- '.$tag->getTagInfo()."\n";
  63.  63     }
  64.  64     */
  65.  65     //echo "buzzfeed user id is $buzzfeed_id \n";
  66.  66     //echo "monamona user id is $mona_id \n";
  67.  67     $i->getMediaLikers(1462813261661883124);
  68.  68     die(var_dump($i));
  69.  69 /*
  70.  70     foreach ($i as $liker){
  71.  71        json_decode($liker);
  72.  72     }
  73.  73 */
  74.  74     #$i->getUserTags(53112486);
  75. 75     //json_decode($i, true);
  76.  76 } catch (Exception $e) {
  77.  77     echo $e->getMessage();
  78.  78 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement