print $event['meta']['is_deleted'] ? 'm' : 'M'; break; case 'channel': print $event['meta']['is_deleted'] ? 'c' : 'C'; break; case 'channel_subscription': print $event['meta']['is_deleted'] ? 'f' : 'F'; break; default: print "Unknwon type [" . $event['meta']['type'] . "]\n"; break; } } // register that function as the stream handler $app->registerStreamFunction('handleEvent'); // open the stream for reading $app->openStream($stream['endpoint']); // now we want to process the stream. We have two options. If all we're doing // in this script is processing the stream, we can just call: // $app->processStreamForever(); // otherwise you can create a loop, and call $app->processStream($milliseconds) // intermittently, like: while (true) { $counters = array('post' => 0, 'star' => 0, 'user_follow' => 0, 'stream_marker' => 0, 'message' => 0, 'channel' => 0, 'channel_subscription' => 0); // now we're going to process the stream for awhile (60 seconds) $app->processStream(60 * 1000000); echo "\n"; // show some stats echo date('H:i') . " [", $counters['post'], "]posts [", $counters['star'], "]stars [", $counters['user_follow'], "]follow [", $counters['stream_marker'], "]mrkrs [", $counters['message'], "]msgs /min\n"; // then do something else... }