Codebird: Passing Variables?


Hi community,

I’m a novice working with PHP so this may be an extremely simple issue, but in regards to Codebird’s streaming (referencing the example code the developer provided on gitHub), how can I pass a variable to the callback function (if I can at all)?:

function some_callback($message) {

called by:


I have read up on callables with PHP, not completely comfortable with it, but I’ve tried a few suggestions without any success.

Basically, I want to collect a series of replies to a particular account and count the number (and/or stopping after x amount of replies have been collected). So I’m assuming using a variable as a counter would suffice?

The problem is I can’t find a way to initialize the variable outside of some_callback() and pass the value to it. Any insight would be appreciated - just please keep in mind that a direct “here’s exactly how to do it” answer is going to be most helpful … Again, novice here :slight_smile:

Edit: Forgot to mention, I understand I can use $GLOBALS but the Codebird streaming example advises against this (not sure why)? So what is an alternative to passing variables into callbacks?