Constant stream - Per User?(not sure how to correctly title)




So heres my issue… or what I do not understand.
My initial thought was that twitters streaming api would make a post request to the url of my choice, in which i can handle data how ever needed… now after testing and finally playing, this isnt the case…

So, my app needs to get the latest follower/unfollowers and save them to the database. Now… this works, but only when i directly run the URL i need to.

Heres an example of my code:

    $GLOBALS['time_start'] = time();
    $account = TwitterAccounts::find(8);
    $this->twitter->updateToken($account->token, $account->refresh_token);
    $this->twitter->getApi()->setStreamingCallback(function ($message)
        if ($message !== null) {

                switch ($message->event)
                    case "follow":

                            'account_id' => $message->target->id,
                            'followed_by_account_id' => $message->source->id,
                        echo "{$message->target->screen_name} followed {$message->source->screen_name} <br>";
                       // return true;
                        return false;
                    case "unfollow":
                        echo "{$message->source->screen_name} unfollowed {$message->target->screen_name} <br>";
                        return false;
                    case "user_update":
                        //When the user update their information
        if (time() - $GLOBALS['time_start'] >= 60) {
            return true;

        return false;

    return $this->twitter->getApi()->user();

Sorry this is hard to explain, but… now, when a user is using the app, if their account receives a new follow or they follow a user, it would be automatically added to the database… but this only works if the url is being run, so how do i handle this?

If i were to remove the parts that close the stream, how would the stream start originally. Would i Cronjob it?
If i were to use the one stream like i have here, I dont understand how the token and stuff will differ from user to user



Bump… ^^