Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7809585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:29:12+00:00 2026-06-02T03:29:12+00:00

I’m at a logical roadblock on how to implement something I’m doing. I’m working

  • 0

I’m at a logical roadblock on how to implement something I’m doing. I’m working with the Instagram API(not important to this question) and in their JSON response they give you 20 results and a link to the next 20 results. I’m trying to build an OOP library that can get the response from the initial API call, search if it has a “next_url” value, and if it does, get the next 20 responses and so un until there’s no longer an next URL. I can’t quite gather the logic on how to do this…

currently here’s the code to get the the first 20…

function __apiCall($url, $post_parameters = FALSE) {

        $curl_session = curl_init();

        curl_setopt($curl_session, CURLOPT_URL, $url);

        if($post_parameters !== FALSE) {
            curl_setopt ($curl_session, CURLOPT_POSTFIELDS, $post_parameters);
        }

        // Return the curl results to a variable
        curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, 1);

        curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, $this->codeigniter_instance->config->item('instagram_ssl_verify'));

        $contents = curl_exec ($curl_session);

        curl_close ($curl_session);

        $return = json_decode($contents);
        return $return;


    }

and here’s a snippet from the JSON response….

    stdClass Object
(
    [pagination] => stdClass Object
        (
            [next_url] => https://api.instagram.com/v1/locations/3937885/media/recent?min_timestamp=&min_id=&max_timestamp=&access_token=xxxxxxxxxxxx49414762bea69258210d8872&max_id=133226850290424667_21341717
            [next_max_id] => 133226850290424667_21341717
        )

    [meta] => stdClass Object
        (
            [code] => 200
        )

    [data] => Array
        (
            [0] => stdClass Object
                (
                    [tags] => Array
                        (
                        )

                    [type] => image
                    [location] => stdClass Object
                        (
                            [latitude] => 39.95022
                            [name] => Neiman Group
                            [longitude] => -75.168322
                            [id] => 3937885
                        )

                    [comments] => stdClass Object
                        (
                            [count] => 0
                            [data] => Array
                                (
                                )

                        )
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T03:29:14+00:00Added an answer on June 2, 2026 at 3:29 am
    function getResults($url)
    {
        $gotAllResults = false;
        $results = array();
    
        while(!$gotAllResults) {
            $result = $this->__apiCall($url);
            $results[] = $result;
    
            if (!property_exist($result->pagination, 'next_url') {
                $gotAllResults = true;
            } else {
                $url = $result->pagination->next_url;
            }
        }
    
        return $results;
    }
    
    function __apiCall($url)
    {
            // settings for cURL
    
            $contents = curl_exec($curl_session);
    
            curl_close ($curl_session);
    
            $result = json_decode($contents);
            return $return;
    }
    

    BTW. Why are you using two underscores in the name of your __apiCall function. That makes me think something magical is happening.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am doing a simple coin flipping experiment for class that involves flipping a
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I need a function that will clean a strings' special characters. I do NOT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.