Reputation: 285
I have a problem, I'm running a script and the PHP line duplicates to whatever number $num_newlines equals. This is what I am currently using:
for ($i=1; $i<=($num_newlines - 1); $i++) {
$tweetcpitems->post('statuses/update', array('status' => wordFilter("The item $array[$i] has been released on Club Penguin.")));
}
What I want to do is have 90 second intervals between however many duplicates are made. So I'm not tweeting like 50 times within 10 seconds. What I want to do is add a 90 second interval between each tweet, please help!
Upvotes: 0
Views: 1627
Reputation: 14992
Two options:
If you can set up CRON jobs - create a queue of messages to post (in a database or file) and let a script run every 90 seconds that takes and removes one message from the queue and sends it.
Use sleep
function inbetween sending messages. Note that you may need to increase the time limit (from the comments: under Linux, sleeping time is ignored, but under Windows, it counts as execution time).
Upvotes: 1
Reputation: 6732
Use the sleep()
function:
for ($i = 1; $i <= $num_newlines - 1; $i ++) {
$tweetcpitems->post('statuses/update', array('status' => wordFilter('The item ' . $array[$i] . ' has been released on Club Penguin.')));
sleep(90);
}
This snippet sleeps after every tweet, also after the last one. To prevent sleeping unnecessary after the last tweet, use this:
for ($i = 1; $i <= $num_newlines - 1; $i ++) {
$tweetcpitems->post('statuses/update', array('status' => wordFilter('The item ' . $array[$i] . ' has been released on Club Penguin.')));
if ($i <= $num_newlines - 1) {
sleep(90);
}
}
Upvotes: 1