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 6935027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:02:50+00:00 2026-05-27T12:02:50+00:00

I need some advice on debugging the code below please. I’m feeding in Twitter

  • 0

I need some advice on debugging the code below please.

I’m feeding in Twitter user ids from $userIDArray. Because of Twitter limitations I have to break the calls up into batches of 100. So, if $userIDarray contains 512 users, I’m making 6 simultaneous calls using curl_multi_exec.

When I look at the return data the first batch of 100 responses is always fine, then after that I’m getting batches of only 0 and 1 results being returned. So, from 512 users I might only get return info for 120.

How do I find out what is happening with these calls please?

function getUserInfo()
{
    global $userIDArray;
    global $counter;
    global $userInfoArray;
    $handleArray = array();

    $requiredCalls = ceil($counter / 100);
    echo "Calls ".$requiredCalls."</br>";

    $mh = curl_multi_init();

    for($i = 0; $i < $requiredCalls; $i++) 
    {
        $counterLow = $counter - 100;

        if($counterLow < 0)
        {
            $counterLow = 0;    
        }

        //Take only 100 items
        $outputUIDArray = array_slice($userIDArray,$counterLow, $counter);

        //Implode array to string of user ids
        $uids = implode(",", $outputUIDArray);
        //echo "UIDs = ".$uids;

        $handle=curl_init();
        curl_setopt($handle,CURLOPT_URL,'https://api.twitter.com/1/users/lookup.json?user_id='.$uids.'&include_entities=false');
        curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1);


        $handleArray[] = $handle;

        curl_multi_add_handle($mh,$handleArray[$i]);

        echo "Counter low ".$counterLow." Counter high ".$counter."</br>";

        $counter -= 100;
    }

    $active = null;
    //execute the handles
    do {
        $mrc = curl_multi_exec($mh, $active);
        } while ($mrc == CURLM_CALL_MULTI_PERFORM);

    while ($active && $mrc == CURLM_OK) {
        if (curl_multi_select($mh) != -1) {
            do {
                $mrc = curl_multi_exec($mh, $active);
            } while ($mrc == CURLM_CALL_MULTI_PERFORM);
        }
    }


    for($i = 0; $i < $requiredCalls; $i++) 
    {   
        //Get result
        $result = curl_multi_getcontent ($handleArray[$i]);
        //echo( $i . "\n" . $results . "\n");

        $json_a=json_decode($result,true);
        echo count($json_a)."</br>";
        //print_r($json_a);

        for($j = 0; $j < count($json_a); $j++)
        {
            $userInfoArray[] = $json_a[$j];
        }

        var_dump(curl_multi_info_read($mh));
        echo"</br>";

        //close the handles
        curl_multi_remove_handle($mh, $handleArray[$i]);
    }


    curl_multi_close($mh);  

    echo "Results in final array ".count($userInfoArray);}
  • 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-05-27T12:02:51+00:00Added an answer on May 27, 2026 at 12:02 pm

    I was misinterpreting how array slice works

    $outputUIDArray = array_slice($userIDArray,$counterLow, $counter);
    

    Should be

    $outputUIDArray = array_slice($userIDArray,$counterLow, 100);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some advice and possible code examples for parsing an HTML table from
I need some advice from experts :) I will develop a website using PHP
Help, I am a noob, just need some advice on this bit of code.
Alright, I need some advice and best practices from some Rails people. I'm fairly
I need some advice, because I am new to c++ For my wind turbine
I need some advice regarding the use of a command line utility from a
I need some advice on how I can change the implementation of some code.
Need some advice again please. This is regarding a single developer shop. I have
I need some advice as to how I easily can separate test runs for
I need some advice on what kind of pattern(s) I should use for pushing/pulling

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.