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

  • SEARCH
  • Home
  • 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 8704749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:11:15+00:00 2026-06-13T03:11:15+00:00

I built an php cli script that ouputs tweets from twitter streaming api to

  • 0

I built an php cli script that ouputs tweets from twitter streaming api to the commandline with cURL. When I start the script it begins outputting tweets, but at every 50th tweet I get the following error: “Easy there, Turbo. Too many requests recently. Enhance your calm.”, no headers, no other ouput, just a string.

I assume I make too many connections, but I only init the cURL once. Here’s my code:

//initialize cURL connection
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://stream.twitter.com/1.1/statuses/filter.json?  follow=34572451,27260086');
curl_setopt($ch, CURLOPT_USERPWD, 'USERNAME:PASSWORD');
curl_setopt($ch, CURLOPT_WRITEFUNCTION, 'saveTweet');
curl_setopt($ch, CURLOPT_MAXCONNECTS, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_FORBID_REUSE, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Cache-Control: max-age=0', 'Connection: keep-alive', 'Keep-Alive: 3600'));

//then loop the execution to retrieve tweets
while(1){
    echo $i++.'->'; //echo number, so we know it stops at 50

    try {
        //calls saveTweet() as callback, which only purpose is to output the tweet
        curl_exec($ch); 
    }
    catch(Exception $e) {
        //echo error described above
        echo $e->getMessage(); 
        break;
    }
}

How do I prevent cURL from making too many requests (if it does that, I don’t really know the exact problem)? Or how do I prevent getting the above error?

  • 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-13T03:11:16+00:00Added an answer on June 13, 2026 at 3:11 am

    You can run endless loop like that you need to sleep and usleep once in a while

    sleep(1);
    

    You would also like to look at count option count :

    Specifies the number of records to retrieve. Must be less than or equal to 200. Defaults to 20.

    This way you can pull more record with a single request …

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

Sidebar

Related Questions

After using PHP for a while now, I've noticed that not all built-in PHP
when i use php -v in terminal showing PHP 5.3.6-13ubuntu3.9 with Suhosin-Patch (cli) (built:
I built a php site that is hosted with an ISP. A friend who
When I use the built in php mail function, the php script hangs for
I have an applicaion built with php mysql that handles invoicing of subcontractors for
I have a Facebook app that is built in PHP and have added a
I have a C# application that needs to call a PHP script, and get
I am using PHP 5 on my dedicated linux server 5.2.6 (cli) (built: May
I can run my script just fine from the command line: php test.php and
Environment PHP -V output: PHP 5.3.5-1ubuntu7.2 with Suhosin-Patch (cli) (built: May 2 2011 23:00:17)

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.