Skip to content

straux/AnyEvent-Gnip-Stream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

NAME

AnyEvent::Gnip::Stream - Receive Gnip Power Track streaming API in an event loop

SYNOPSIS

use AnyEvent::Gnip::Stream;

# receive updates from Gnip Power Track
my $done = AE::cv;
my $listener = AnyEvent::Gnip::Stream->new(
    user     => $user,
    password    => $password,
    stream_url  => $stream_url,
    on_tweet    => sub {
        my $tweet = shift;
        print $tweet->{actor}->{preferredUsername}.": ".$tweet->{body}."\n";
    },
    on_error    => sub {
        warn shift."\n";
        $done->send;
    },
    on_connect  => sub {
        print "Stream started!\n";
    },
    on_eof      => sub {
        warn "EOF\n";
        $done->send;
    },
    on_keepalive => sub {
      warn "ping\n";
    },
    timeout => 60,
);
$done->recv;

DESCRIPTION

AnyEvent::Gnip::Stream is an AnyEvent user to receive Gnip Power Track streaming API, available at http://docs.gnip.com/w/page/35663947/Power-Track and http://docs.gnip.com/w/page/37218164/Getting%20Started%20with%20Commercial%20Twitter%20Data.

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

METHODS

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

user password

These arguments are used for basic authentication.

stream_url

URL of the Gnip collector to link to.

timeout

Set the timeout value.

on_connect

Callback to execute when a stream is connected.

on_tweet

Callback to execute when a new tweet is received.

on_error

Callback to execute when an error occurs.

on_eof
on_keepalive
no_decode_json

Set this param to TRUE if you don't want to deserialize json input from the stream.

NOTES

The API uses the HTTPS protocol. For this, you need to install the Net::SSLeay module.

AUTHOR

Stéphane Raux <[email protected]>

(Based on Tatsuhiko Miyagawa's AnyEvent::Twitter::Stream)

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::Stream

About

Receive Gnip Power Track streaming API in an event loop

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages