Load more than 12 Pictures Instagram API/PHP

Status
Not open for further replies.
Edited my last message, with updated code, images should't repeat now.
 
OMGGGG THANK YOU MEEEN!!! Give me your paypal i show my thanks!

Can u only do one more thing? Can u put a button on the side then if someone klicks the button 12 more pictures load.
 
I guess I can't take money from you because I think that would count as selling services without Jr.Vip account or something similar. I will look later, about loading more pictures button.
 
ah ok.. Thank you very very much sir!
 
If I didn't miss anything, this should work. Style your button as you want. It's not the best method, but it should work. Btw code wise this script, is ugly af.

PHP:
<?php
/**
 * Template Name: order instagram like Template
 * A full-width template.
 *
 * @package Avada
 * @subpackage Templates
 */
get_header();
// Do not allow directly accessing this file.
if ( ! defined( 'ABSPATH' ) ) {
    exit( 'Direct script access denied.' );
}
error_reporting(0);
 if(isset($_REQUEST['instagram'])){
     //$uname='business_mafia';
      $uname=$_REQUEST['username'];
      $username=strtolower(str_replace(' ','_',$uname));
      $url="https://www.instagram.com/$username/?__a=1";
      $userinfo = file_get_contents($url);
      $userdata = json_decode($userinfo,true);
      $user=$userdata['user'];
      $iteration_url = $url;
      if(!empty($user)){
          $followers=$user['followed_by']['count']; echo '</br>';
          $follow=$user['follows']['count']; echo '</br>';
          $fullname= $user['full_name']; echo '</br>';
           $usernamee=$user['username']; echo '</br>';
          $profilepic=$user['profile_pic_url_hd'];
          $limit = 24;
          $tryNext = true;
          $found = 0;
          $images_all = array();
          while ($tryNext) {
              $tryNext = false;
           
              $remote = file_get_contents( $iteration_url );
           
              $response = $remote;
   
              if ($response === false) {
                  return false;
              }
              $data = json_decode($response, true);
           
              if ( $data === null) {
                  return false;
              }
              $media = $data['user']['media'];
   
              foreach ( $media['nodes'] as $index => $node ) {
                  if ( $found + $index < $limit ) {
                      if (isset($node['is_video']) && $node['is_video'] == true) {
                          $type = 'video';
                      } else {
                          $type = 'image';
                      }
                      $image = array(
                          'link' => 'https://instagram.com/p/' . $node['code'],
                          'comments' => $node['comments']['count'],
                          'likes' => $node['likes']['count'],
                          'thumbnail' => $node['thumbnail_src'],
                          'small' => $node['thumbnail_src'],
                          'full' => $node['display_src'],
                          'original' => $node['display_src']
                      );
                      array_push($images_all, $image);
                  }
              }
   
              $found += count($media['nodes']);
   
   
              if ( $media['page_info']['has_next_page'] && $found < $limit ) {
                  $iteration_url = $url . '&max_id=' . $media['page_info']['end_cursor'];
                  $tryNext = true;
              }
          }
          $massage="success";
     
 
      } else{
          //echo 'User name does not exite';
          $massage='error';
      }
    }
 
  global $woocommerce;
  $product_id=$_REQUEST['add-to-cart'];
?>

<div class=" order-container" style="">
    <div>
        <div class="row order-row">
            <div class="col-sm-8 col-xs-12 order-left">
                <div class="order-title">Order Form</div>
                <div class="order-left-wrap">
                    <form id="follower" data-toggle="validator" method="post" <?php if($massage=='success'){ echo "style='display:none'"; } ?> >
                        <div class="form-group">
                            <label for="username" id="ask_label">Instagram Username *</label>
                            <input type="text" name="username" class="form-control required name" id="username"  placeholder="Please enter your Instagram username" required>
            <?php if($massage=='error'){ ?>  <p class="form-val" style="display: block;">Please enter valid instagram username. OR Instagram user have to be Public</p> <?php } ?>
                        </div>
                        <div class="form-group">
                            <label for="email">Email Address *</label>
                            <input type="email" autocapitalize="none" name="email" class="form-control" id="email" placeholder="Please enter your email address." required>
                       
                        </div>
                        <br>
                        </br>
               
                        <button type="submit" name="instagram" class="btn btn-primary btn-lg crv-btn" id="devam" >
                        Continue &gt;
                        </button>
                    </form>
                    <!-- user details and payment details -->
                    <div id="followers" style="<?php if($massage=='success'){ echo 'display:flex'; }else { echo 'display:none'; }  ?> ">
                        <div class="follower-img">  <img class="follower-img-inner" src="<?php echo $profilepic; ?>"></div>
                        <div class="follow-info">
                            <h1><?php echo $usernamee; ?></h1>
                            <h2><?php echo $fullname; ?></h2>
                            <p id="follows">Following : <span><?php echo $follow; ?></span></p>
                            <p id="following">Followers : <span><?php echo $followers; ?></span></p>
                            <!--<p id="media-count">Media : <span>11</span></p> -->
                        </div>
                        <p class="follow-warn"></p>
                   
                    </div>
                            </script>
   
                    <script>
                        jQuery(document).ready(function($) {
 
                            $(".cbox").on("click", function() {
                                var numberOfChecked = $('input.cbox:checkbox:checked').length;
                                var totalimg=$('#totalimg').val();
                                if (numberOfChecked > totalimg) {
                                    $(this).prop('checked', false);
                                }
                            });
 
                        });
                        </script>
            <style type="text/css">
                .images{
                    display:none;
                }
                #loadMoreButton{
                    padding: 10px;
                    text-align: center;
                    background-color: #33739E;
                    color: #fff;
                    border-width: 0 1px 1px 0;
                    border-style: solid;
                    border-color: #fff;
                    box-shadow: 0 1px 1px #ccc;
                    transition: all 600ms ease-in-out;
                    -webkit-transition: all 600ms ease-in-out;
                    -moz-transition: all 600ms ease-in-out;
                    -o-transition: all 600ms ease-in-out;
                }
            </style>
        <?php  if($massage=='success'){ ?>
        <form name="checkout" method="post" class="checkout woocommerce-checkout" action="<?php echo esc_url( wc_get_checkout_url() ); ?>" enctype="multipart/form-data">
        <div class="col-1">
        <input type="hidden" name="usernameinst" value="<?php echo $usernamee; ?>" />
            <div class="image-like" >
                    <ul>
                     <?php
                       $select_image = get_post_meta( $product_id, 'like_image', true );
                       $count=0;
                       foreach($images_all as $imagede){
                         $img=$imagede['original'];
                         $link=$imagede['link'];
                     
                       // echo '<img src='."'$img'".' class="image-class img-check"><input type="checkbox" name="select_images[]" value='."'$link'".'>';                    
                        ?>
                        <li class="ig-label" class="imagesClass"><input type="checkbox" class="cbox" name="select_images[]" id="cb<?php echo $count; ?>" value="<?php echo $link; ?>" />
                          <label for="cb<?php echo $count; ?>"><img src="<?php echo $img; ?>" />
                          <p class="ig-meta">
                            <span class="ig-likes"><?php echo $imagede['like']; ?> likes</span>
                            <span class="ig-comments"><?php echo $imagede['comment']; ?> comments</span>
                            <span class="ig-views"></span>
                            <span class="ig-instruct">Click to select</span>
                          </p>
                          </label>
                     
                        </li>
                    <?php   $count++; } ?>
                    <input type="hidden" id="totalimg" value="<?php echo $select_image; ?>" />
                    </ul>
<div>
                       <a href="" id="loadMoreButton">Load More</a>
</div>
                    <i class="fa fa-heart fa-2x" aria-hidden="true" ></i><span class="select-image"> You can split likes on <?php echo $select_image; ?> Pictures
                    </span>
                    </div>
            <div class="woocommerce-billing-fields avada-select">
                <h3 class="row-title" data-fontsize="18" data-lineheight="25"></h3>
                    <div class="theme_box">
                        <div class="row">
                     
                        </div>
            <script>
            jQuery(function () {
                $(".imagesClass").slice(0, 12).show();
                $("#loadMoreButton").on("click", function (e) {
                    e.preventDefault();
                    $(".imagesClass:hidden").slice(0, 12).slideDown();
                    if ($(".imagesClass:hidden").length == 0) {
                        $("#loadMoreButton").fadeOut("slow");
                    }
                });
            });</script>
            </div><!--/ .theme_box-->
 
            </div>
        </div>
 
 
            <div id="order_review" class="woocommerce-checkout-review-order">
                <?php do_action( 'woocommerce_checkout_order_review' ); ?>
            </div>
        </form>
   
        <?php } ?>
               
                </div>
                </div>
                <div class="col-sm-4 order-right">
                <div class="order-title detay-title">Order Details</div>
                <div class="order-right-wrap">
                <ul class="list-group">
                <li class="i order_ozellik"><img class="check_png lazyloaded" src="../wp-content/uploads/2018/01/check.png" data-was-processed="true"><?php echo get_the_title($product_id); ?></li>
                 <?php //echo  get_post($product_id)->post_content; ?>
                 <li><img class="check_png lazyloaded" src="../wp-content/uploads/2018/01/check.png">High Quality Likes</li>
                <li><img class="check_png lazyloaded" src="../wp-content/uploads/2018/01/check.png">All Real &amp; Active</li>
                <li><img class="check_png lazyloaded" src="../wp-content/uploads/2018/01/check.png">100% Safe</li>
                <li><img class="check_png lazyloaded" src="../wp-content/uploads/2018/01/check.png">No Password Required</li>
                <li><img class="check_png lazyloaded" src="../wp-content/uploads/2018/01/check.png">Instant Delivery</li>
                <li><img class="check_png lazyloaded" src="../wp-content/uploads/2018/01/check.png">24/7 Support</li>
                </ul>
                <ul class="summer"><li class="list-group-item">Total: <span><?php echo $total=$woocommerce->cart->get_cart_subtotal(); ?></span></li></ul></div>
            </div>
            </div>
   
    </div>
</div>
 
<?php get_footer(); ?>
 
Last edited:
I know i should learn how to code with structure. But i am a newbie php guy :D i think for my purpose it works fine.
The Button Load more is there but if i click it it redirect me back to the previous page
 
Hey
nope still not loading more. it only goes to the top of the page this time instead of going to the prev. page
 
Again updated post, with code. If it doesn't work I can't help, when I don't see, live website source code, because there are too many variables, why exactly that doesn't work.
 
Nope that doesnt work again.. i send u website url
 
Again updated post, with code. If it doesn't work I can't help, when I don't see, live website source code, because there are too many variables, why exactly that doesn't work.
Hey Rimvy, would you be able to help me out with this as well? I am not able to message anyone. I think it's because I'm still a newbie.
 
I need exactly this. If someone have something like this for wordpress please pm me
 
Guys,
It didnt work with normal methods.
Because of the API limitation to load maximum 12 pictures.

Solution was to end a request after obtaining 12 Pictures.
Create a new request with a button that says "load more pictures" ( for example ) and let that button obtain another 12 pictures just this time with offset -12 ( so he starts with the 13 picture )
in my case ( all programmed into Wordpress ) took me over 3 months to find a way to get this done. i see many websites that have that already since months.

maybe i am too low in programming but now it works fine and is used and much appreaciated from my customers.

Thanks for the from my posting guys here <3 love ya
 
Guys,
It didnt work with normal methods.
Because of the API limitation to load maximum 12 pictures.

Solution was to end a request after obtaining 12 Pictures.
Create a new request with a button that says "load more pictures" ( for example ) and let that button obtain another 12 pictures just this time with offset -12 ( so he starts with the 13 picture )
in my case ( all programmed into Wordpress ) took me over 3 months to find a way to get this done. i see many websites that have that already since months.

maybe i am too low in programming but now it works fine and is used and much appreaciated from my customers.

Thanks for the from my posting guys here <3 love ya
does it fetching the video posts fine? i see video posts are not fetched from last week.
 
does it fetching the video posts fine? i see video posts are not fetched from last week.
It has to. I am selling Video Likes for IG too and today i got few orders so it has to work. i will test it later
 
Guys,
It didnt work with normal methods.
Because of the API limitation to load maximum 12 pictures.

Solution was to end a request after obtaining 12 Pictures.
Create a new request with a button that says "load more pictures" ( for example ) and let that button obtain another 12 pictures just this time with offset -12 ( so he starts with the 13 picture )
in my case ( all programmed into Wordpress ) took me over 3 months to find a way to get this done. i see many websites that have that already since months.

maybe i am too low in programming but now it works fine and is used and much appreaciated from my customers.

Thanks for the from my posting guys here <3 love ya

This is also favourable because you aren't spamming Instagram with API requests. It'll mean you aren't requesting 100 photos etc every time someone loads the page.
 
It has to. I am selling Video Likes for IG too and today i got few orders so it has to work. i will test it later
I want to create wordpress site for selling likes followers etc..Are you just selling video likes or followers etc as well? And can you share it with me,for a fee if necessary because i am also searching for weaks and couldnt find and i am not too good at php like you and english is not my main language,so i am having troubles :)
 
Again updated post, with code. If it doesn't work I can't help, when I don't see, live website source code, because there are too many variables, why exactly that doesn't work.


hello sir i need a help ..i have a script instagram downloader post..there show only 12 post i want to show more ...
 
Status
Not open for further replies.
Back
Top