twitteruserstream.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * PHP version 5
  6. *
  7. * LICENCE: This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU Affero General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. * @category Plugin
  21. * @package StatusNet
  22. * @author Brion Vibber <brion@status.net>
  23. * @copyright 2010 StatusNet, Inc.
  24. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  25. * @link http://status.net/
  26. */
  27. /**
  28. * Stream listener for Twitter User Streams API
  29. * http://dev.twitter.com/pages/user_streams
  30. *
  31. * This will pull the home stream and additional events just for the user
  32. * we've authenticated as.
  33. */
  34. class TwitterUserStream extends TwitterStreamReader
  35. {
  36. public function __construct(TwitterOAuthClient $auth, $baseUrl='https://userstream.twitter.com')
  37. {
  38. parent::__construct($auth, $baseUrl);
  39. }
  40. public function connect($method='2/user.json')
  41. {
  42. return parent::connect($method);
  43. }
  44. /**
  45. * Each message in the user stream is just ready to go.
  46. *
  47. * @param array $data
  48. */
  49. function routeMessage(stdClass $data)
  50. {
  51. $context = array(
  52. 'source' => 'userstream'
  53. );
  54. parent::handleMessage($data, $context);
  55. }
  56. }