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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:31:09+00:00 2026-06-10T05:31:09+00:00

From REST API of twitter I user get/followers function. I pasted a code snippet

  • 0

From REST API of twitter I user get/followers function.
I pasted a code snippet below.

My problem is, modt of the time I get followers’ ids successfully. But when a user has more than 5000-6000 followers then my results comes wrong.

When I check from user’s profile page, I see that user has 5500 followers, but when I run following code, most of the time 5500 ids come, but sometimes 29994 followers come inside $ids variable. Now I’m logging the results having more then 29k followers. I saw some of the requests returned with 29994 followers, but I couldn’t find the answer.

Do I miss something in get ids – cursor approach? Thank you

Edit: After some debugging I logged “$cursor_archieve” parameter and found out this:
* Sometimes next_cursor and previous_cursor comes same:

Array
(
    [0] => -1
    [1] => 1400573121087317741
    [2] => 1400573121087317741
    [3] => 1400573121087317741
    [4] => 1400573121087317741
    [5] => 1400573121087317741
    [6] => 1400573121087317741
)

So in this situation, although user has 7100 followers I get only 5000 followers

  • Sometimes cursors come sequentially same:

    Array
    (
    [0] => -1
    [1] => 1404335879106773348
    [2] => 1404341060469987526
    [3] => 1404338682006540390
    [4] => 1404341060469987526
    [5] => 1404335879106773348
    [6] => 1404338682006540390
    )

My code is like this:

public function getIds($user = "someuser"){
    $tmhOAuth = new tmhOAuth(array( 'consumer_key'    => YOUR_CONSUMER_KEY, 
              'consumer_secret' => YOUR_CONSUMER_SECRET,
              'user_token'      => $atoken1, 'user_secret'     => $atoken2, ));

    $cursor = '-1';
    $ids = array();
    $cursor_archieve = array();
    while(true):
        $code=$tmhOAuth->request('GET', $tmhOAuth->url('1/followers/ids'),
                array('screen_name' => $user, 'cursor' => $cursor));

        if ($code == 200) {
            $responseData = json_decode($tmhOAuth->response['response'],true);
            $ids = array_merge($ids, $responseData['ids']);
            $cursor = $responseData['next_cursor_str'];
                    $cursor_archieve[] = $cursor;
        } else {
            return 0;
        }
        if ( $cursor == '0' || count($ids) >= 29000 ) {
            break;
        }
    endwhile;

    return $ids;
}

edit2: Should I make “array_unique” to delete duplicate ids, or doesn’t use next cursor if previous_cursor=next cursor or any other option?
In every case user has 5500-6500 followers. So If I take only one cursor, I only can get first 5000 followers.

  • 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-10T05:31:10+00:00Added an answer on June 10, 2026 at 5:31 am

    The reason was a programatic error in my codes. I fixed it after a week’s debug session

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

Sidebar

Related Questions

I get the following text as a string from an XML-based REST API 'd':4
My problem is when I get a string from the REST service and set
A consumer is trying to call my REST API from client-side code (Javascript /
I have an NSArray built from json data from twitter REST API. NSArray *dict
I'm using the Rally REST API to integrate user story data from Rally into
What's the REST API call required to undo/remove/destroy/delete a retweet (of another user) from
I try to learn REST in Ruby using Twitter API. According https://dev.twitter.com/docs/api/1/get/trends I have
When I get the json from the rest api, it comes in plain text.
I tried get data from rest api using http requests and evenmachine. For this
Is there an easy way to generate docs for REST api direct from a

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.