Help with codebird library



Hi everyone,

I’m developing a php web application using codebird php library and I was wondering if any of you can help me, I tried to connect to a endpoint but my english is so bad and I don’t understand the documentation, if you can send me an example to view how to connect and make a track request I’d appreciate it very much.

Now i have that code:

 \Codebird\Codebird::setConsumerKey('CONSUMER KEY', 'CONSUMER SECRET');

 $cb = \Codebird\Codebird::getInstance();
 $cb->setToken('TOKEN KEY', 'TOKEN SECRET');

 function some_callback($message){
   if ($message !== null) {
	echo "<p>";
	echo "</p>";
   if (time() - $GLOBALS['time_start'] >= 60) {
  	return true;
   return false;
 $GLOBALS['time_start'] = time();
 $reply = $cb->statuses_filter('track=happy');

How can i do that the request never stop automatically?



The code you showed will stop after 60 seconds. Your callback function (some_callback) return parameter controls when Codebird should stop consuming the streaming API:

  • return false if you don’t want to stop yet
  • return true if you want to stop now

So, to continue infinitely, just remove the if-condition (if (time() - $GLOBALS…) along with its curly braces and content.


Oh, thanks Jublonet, then if i return false all time the stream don’t stop.

Thanks mate!


Unless your PHP script is killed –