The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

POE::Component::RSSAggregator - A Simple POE RSS Aggregator

SYNOPSIS

    use POE;
    use POE::Component::RSSAggregator;
    use XML::RSS::Feed::Factory;

    my @feeds = (
        {
            url   => "http://www.jbisbee.com/rdf/",
            name  => "jbisbee",
            delay => 10,
            debug => 1,
        },
        {
            url   => "http://lwn.net/headlines/rss",
            name  => "lwn",
            delay => 300,
            debug => 1,
        },
    );

    POE::Session->create(
        inline_states => {
            _start      => \&init_session,
            handle_feed => \&handle_feed,
        }
    );

    $poe_kernel->run();

    sub init_session
    {
        my ($kernel, $heap, $session) = @_[KERNEL, HEAP, SESSION];
        $heap->{rssagg} = POE::Component::RSSAggregator->new(
            feeds    => [feed_factory(@define_feeds)],
            debug    => 1,
            callback => $session->postback("handle_feed"),
        );
    }

    sub handle_feed
    {
        my ($heap,$kernel,$feed) = (@_[HEAP, KERNEL], $_[ARG1]->[0]);
        for my $headline ($feed->late_breaking_news) {
            # do stuff with the XML::RSS::Headline object
            print $headline->headline . "\n";
        }
    }

USAGE

The premise is this, you watch RSS feeds for new headlines to appear and when they do you trigger an event handle them. The handle_feed event is given a XML::RSS::Feed object every time new headlines are found.

AUTHOR

Jeff Bisbee CPAN ID: JBISBEE jbisbee@cpan.org http://search.cpan.org/author/JBISBEE/

COPYRIGHT

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

The full text of the license can be found in the LICENSE file included with this module.

SEE ALSO

XML::RSS::Feed::Factory, XML::RSS::Feed, XML::RSS::Headline