tags:

views:

87

answers:

1

Hello all,

Consider this:

require 'Twitter.class.php';
$tweet = new Twitter("username", "password");

foreach($comment as $key => $value) {
     $link = $db->get_row("sql query");
            //sleep(10;)    
     $tweet->update('$link');
    }
}

This makes a new twitter message for every loop, the loop happens about 10 times and I expect 10 twitter messages to be sent to my account. However, at best only 1 or 2 arrive.

Is there a time that I have to wait between tweets? I have tried the sleep function but that didn't solve anything. Do I need to wait for longer? I couldn't find anything much in the documentation.

Before I attempt something such as saving tweets to a DB and using a cron job or something to process the tweets. I prefer to get it working in the above. Please help. :)

Thanks all

+2  A: 

When looking at the example.php, there is an optional third parameter to the Twitter constructor. If you add a true to as that third parameter, you get an output dump of the data being sent and received. Try turning that on and seeing what happens.

But, to answer the specific question, there are limits on the Twitter API for how quickly/how much you can do in one hour. See the Twitter API FAQ for information about that. When you were testing, you might have accidentally triggered a blacklist of your IP address. The debug info from Twitter should help.

If that isn't enough, you can add a proxy between your PHP code and Twitter (as recommended in the Twitter FAQ) to see the return values; you might be getting some "Stop sending so many updates" type of message that the Twitter PHP code is silently dropping.

Tony Miller