Giter Site home page Giter Site logo

anyevent-gnip-stream's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.