GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  ANYEVENT::TWITTER::STREAM (3)

.ds Aq ’

NAME

AnyEvent::Twitter::Stream - Receive Twitter streaming API in an event loop

CONTENTS

SYNOPSIS



  use AnyEvent::Twitter::Stream;

  # receive updates from @following_ids
  my $listener = AnyEvent::Twitter::Stream->new(
      username => $user,
      password => $password,
      method   => "filter",  # "firehose" for everything, "sample" for sample timeline
      follow   => join(",", @following_ids), # numeric IDs
      on_tweet => sub {
          my $tweet = shift;
          warn "$tweet->{user}{screen_name}: $tweet->{text}\n";
      },
      on_keepalive => sub {
          warn "ping\n";
      },
      on_delete => sub {
          my ($tweet_id, $user_id) = @_; # callback executed when twitter send a delete notification
          ...
      },
      timeout => 45,
  );

  # track keywords
  my $guard = AnyEvent::Twitter::Stream->new(
      username => $user,
      password => $password,
      method   => "filter",
      track    => "Perl,Test,Music",
      on_tweet => sub { },
  );

  # to use OAuth authentication
  my $listener = AnyEvent::Twitter::Stream->new(
      consumer_key    => $consumer_key,
      consumer_secret => $consumer_secret,
      token           => $token,
      token_secret    => $token_secret,
      method          => "filter",
      track           => "...",
      on_tweet        => sub { ... },
  );



DESCRIPTION

AnyEvent::Twitter::Stream is an AnyEvent user to receive Twitter streaming API, available at <http://dev.twitter.com/pages/streaming_api> and <http://dev.twitter.com/pages/user_streams>.

See track.pl in eg for more client code example.

METHODS

my CW$streamer = AnyEvent::Twitter::Stream->new(%args);

<B>usernameB> <B>passwordB> These arguments are used for basic authentication.
<B>consumer_keyB> <B>consumer_secretB> <B>tokenB> <B>token_secretB> If you want to use the OAuth authentication mechanism, you need to set use arguments
<B>consumer_keyB> <B>consumer_secretB> <B>tokenB> <B>token_secretB> If you want to use the OAuth authentication mechanism, you need to set these arguments
<B>methodB> The name of the method you want to use on the stream. Currently, anyone of :
<B>firehoseB>
<B>sampleB>
<B>userstreamB> To use this method, you need to use the OAuth mechanism.
<B>filterB> With this method you can specify what you want to filter amongst <B>trackB>, <B>followB> and <B>locationsB>.

See <https://dev.twitter.com/docs/api/1.1/post/statuses/filter> for the details of the parameters.

<B>api_urlB> Pass this to override the default URL for the API endpoint.
<B>request_methodB> Pass this to override the default HTTP request method.
<B>timeoutB> Set the timeout value.
<B>on_connectB> Callback to execute when a stream is connected.
<B>on_tweetB> Callback to execute when a new tweet is received.
<B>on_errorB>
<B>on_eofB>
<B>on_keepaliveB>
<B>on_deleteB> Callback to execute when the stream send a delete notification.
<B>on_friendsB> <B>Only with the usertream methodB>. Callback to execute when the stream send a list of friends.
<B>on_direct_messageB> <B>Only with the usertream methodB>. Callback to execute when a direct message is received in the stream.
<B>on_eventB> <B>Only with the userstream methodB>. Callback to execute when the stream send an event notification (follow, ...).
<B>additional agrumentsB> Any additional arguments are assumed to be parameters to the underlying API method and are passed to Twitter.

NOTES

To use the <B>userstreamB> method, Twitter recommend using the HTTPS protocol. For this, you need to set the <B>ANYEVENT_TWITTER_STREAM_SSLB> environment variable, and install the Net::SSLeay module.

AUTHOR

Tatsuhiko Miyagawa <miyagawa@bulknews.net>

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

AnyEvent::Twitter, Net::Twitter::Stream
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 ANYEVENT::TWITTER::STREAM (3) 2014-04-18

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.