function siteStreamForOwner(User $user) { // The user we auth as must be the owner of the application. $auth = twitterAuthForUser($user); if (have_option('apiroot')) { $stream = new TwitterSiteStream($auth, get_option_value('apiroot')); } else { $stream = new TwitterSiteStream($auth); } // Pull Twitter user IDs for all users we want to pull data for $userIds = array(); $flink = new Foreign_link(); $flink->service = TWITTER_SERVICE; $flink->find(); while ($flink->fetch()) { if (($flink->noticesync & FOREIGN_NOTICE_RECV) == FOREIGN_NOTICE_RECV) { $userIds[] = $flink->foreign_id; } } $stream->followUsers($userIds); return $stream; }
while ($flink->fetch()) { if (($flink->noticesync & FOREIGN_NOTICE_RECV) == FOREIGN_NOTICE_RECV) { $users[] = $flink->user_id; } } } else { $user = User::getKV('nickname', $nickname); $users = array($user->id); } $output = array(); foreach ($users as $id) { $user = User::getKV('id', $id); if (!$user) { throw new Exception("No user for id {$id}"); } $auth = twitterAuthForUser($user); $flink = Foreign_link::getByUserID($user->id, TWITTER_SERVICE); $friends->friends = $auth->friendsIds(); dumpMessage($flink, $friends); $timeline = $auth->statusesHomeTimeline(); foreach ($timeline as $status) { $output[] = prepMessage($flink, $status); } } usort($output, function ($a, $b) { if ($a->message->id < $b->message->id) { return -1; } else { if ($a->message->id == $b->message->id) { return 0; } else {