.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.29) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "AnyEvent::Feed 3pm" .TH AnyEvent::Feed 3pm "2016-03-12" "perl v5.22.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" AnyEvent::Feed \- Receiving RSS/Atom Feed reader with XML::Feed .SH "VERSION" .IX Header "VERSION" Version 0.3 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use AnyEvent; \& use AnyEvent::Feed; \& \& my $feed_reader = \& AnyEvent::Feed\->new ( \& url => \*(Aqhttp://example.com/atom.xml\*(Aq, \& ); \& \& $feed_reader\->fetch (sub { \& my ($feed_reader, $new_entries, $feed, $error) = @_; \& \& if (defined $error) { \& warn "ERROR: $error\en"; \& return; \& } \& \& # $feed is the XML::Feed object belonging to that fetch. \& \& for (@$new_entries) { \& my ($hash, $entry) = @$_; \& # $hash a unique hash describing the $entry \& # $entry is the XML::Feed::Entry object of the new entries \& # since the last fetch. \& } \& }); \& \& # Or: \& \& my $feed_reader = \& AnyEvent::Feed\->new ( \& url => \*(Aqhttp://example.com/atom.xml\*(Aq, \& interval => $seconds, \& \& on_fetch => sub { \& my ($feed_reader, $new_entries, $feed, $error) = @_; \& \& if (defined $error) { \& warn "ERROR: $error\en"; \& return; \& } \& \& # see above \& } \& ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module implements some glue between AnyEvent::HTTP and XML::Feed. It can fetch a RSS/Atom feed on a regular interval as well as on customized times. It also keeps track of already fetched entries so that you will only get the new entries. .SH "METHODS" .IX Header "METHODS" .ie n .IP "$feed_reader = AnyEvent::Feed\->new (url => $url, %args)" 4 .el .IP "\f(CW$feed_reader\fR = AnyEvent::Feed\->new (url => \f(CW$url\fR, \f(CW%args\fR)" 4 .IX Item "$feed_reader = AnyEvent::Feed->new (url => $url, %args)" This is the constructor for a new feed reader for the RSS/Atom feed reachable by the \s-1URL \s0\f(CW$url\fR. \f(CW%args\fR may contain additional key/value pairs: .RS 4 .ie n .IP "interval => $seconds" 4 .el .IP "interval => \f(CW$seconds\fR" 4 .IX Item "interval => $seconds" If this is set you also have to specify the \f(CW\*(C`on_fetch\*(C'\fR callback (see below). It will try to fetch the \f(CW$url\fR every \f(CW$seconds\fR seconds and call the callback given by \f(CW\*(C`on_fetch\*(C'\fR with the result. .ie n .IP "headers => $http_hdrs" 4 .el .IP "headers => \f(CW$http_hdrs\fR" 4 .IX Item "headers => $http_hdrs" Additional \s-1HTTP\s0 headers for each \s-1GET\s0 request can be passed in the \f(CW$http_hdrs\fR hash reference, just like you would pass it to the \f(CW\*(C`headers\*(C'\fR argument of the \f(CW\*(C`http_get\*(C'\fR request of AnyEvent::HTTP. .ie n .IP "username => $http_user" 4 .el .IP "username => \f(CW$http_user\fR" 4 .IX Item "username => $http_user" .PD 0 .ie n .IP "password => $http_pass" 4 .el .IP "password => \f(CW$http_pass\fR" 4 .IX Item "password => $http_pass" .PD These are the \s-1HTTP\s0 username and password that will be used for Basic \s-1HTTP\s0 Authentication with the \s-1HTTP\s0 server when fetching the feed. This is mostly sugar for you so you don't have to encode them yourself and pass them to the \&\f(CW\*(C`headers\*(C'\fR argument above. .ie n .IP "on_fetch => $cb\->($feed_reader, $new_entries, $feed_obj, $error)" 4 .el .IP "on_fetch => \f(CW$cb\fR\->($feed_reader, \f(CW$new_entries\fR, \f(CW$feed_obj\fR, \f(CW$error\fR)" 4 .IX Item "on_fetch => $cb->($feed_reader, $new_entries, $feed_obj, $error)" This callback is called if the \f(CW\*(C`interval\*(C'\fR parameter is given (see above) with the same arguments as the callback given to the \f(CW\*(C`fetch\*(C'\fR method (see below). .ie n .IP "entry_ages => $hash" 4 .el .IP "entry_ages => \f(CW$hash\fR" 4 .IX Item "entry_ages => $hash" This will set the hash which keeps track of seen and old entries. See also the documentation of the \f(CW\*(C`entry_ages\*(C'\fR method below. The default will be an empty hash reference. .ie n .IP "max_entry_age => $count" 4 .el .IP "max_entry_age => \f(CW$count\fR" 4 .IX Item "max_entry_age => $count" This will set the maximum number of times an entry is kept in the \f(CW\*(C`entry_ages\*(C'\fR hash after it has not been seen in the feed anymore. The default value is 2 which means that an entry hash is removed from the \f(CW\*(C`entry_ages\*(C'\fR hash after it has not been seen in the feed for 2 fetches. .RE .RS 4 .RE .ie n .IP "$feed_reader\->url" 4 .el .IP "\f(CW$feed_reader\fR\->url" 4 .IX Item "$feed_reader->url" Just returns the url that this feed reader is fetching from. .ie n .IP "$feed_reader\->entry_ages ($new_entry_ages)" 4 .el .IP "\f(CW$feed_reader\fR\->entry_ages ($new_entry_ages)" 4 .IX Item "$feed_reader->entry_ages ($new_entry_ages)" .PD 0 .ie n .IP "my $entry_ages = $feed_reader\->entry_ages" 4 .el .IP "my \f(CW$entry_ages\fR = \f(CW$feed_reader\fR\->entry_ages" 4 .IX Item "my $entry_ages = $feed_reader->entry_ages" .PD This will set the age hash which will keep track of already seen entries. The keys of the hash will be the calculated hashes of the entries and the values will be a counter of how often they have \s-1NOT\s0 been seen anymore (kind of an age counter). After each fetch this hash is updated and seen entries get a value of 0. .ie n .IP "$feed_reader\->fetch ($cb\->($feed_reader, $new_entries, $feed_obj, $error))" 4 .el .IP "\f(CW$feed_reader\fR\->fetch ($cb\->($feed_reader, \f(CW$new_entries\fR, \f(CW$feed_obj\fR, \f(CW$error\fR))" 4 .IX Item "$feed_reader->fetch ($cb->($feed_reader, $new_entries, $feed_obj, $error))" This will initiate a \s-1HTTP GET\s0 on the \s-1URL\s0 passed to \f(CW\*(C`new\*(C'\fR and call \f(CW$cb\fR when done. .Sp \&\f(CW$feed_reader\fR is the feed reader object itself. \f(CW$new_entries\fR is an array reference containing the new entries. A new entry in that array is another array containing a calculated hash over the contents of the new entry, and the XML::Feed::Entry object of that entry. \f(CW$feed_obj\fR is the XML::Feed feed object used to parse the fetched feed and contains all entries (and not just the 'new' ones). .Sp What a 'new' entry is, is decided by a map of hashes as described in the \&\f(CW\*(C`entry_ages\*(C'\fR method's documentation above. .SH "AUTHOR" .IX Header "AUTHOR" Robin Redeker, \f(CW\*(C`\*(C'\fR .SH "SEE ALSO" .IX Header "SEE ALSO" XML::Feed .PP AnyEvent::HTTP .PP AnyEvent .SH "BUGS" .IX Header "BUGS" .SS "Known Bugs" .IX Subsection "Known Bugs" There is actually a known bug with encodings of contents of Atom feeds. XML::Atom by default gives you \s-1UTF\-8\s0 encoded data. You have to set this global variable to be able to use the XML::Feed::Entry interface without knowledge of the underlying feed type: .PP .Vb 1 \& $XML::Atom::ForceUnicode = 1; .Ve .PP I've re-reported this bug against XML::Feed, as I think it should take care of this. XML::Atom should probably just fix it's Unicode interface, but it seems to be a bit deserted w.r.t. fixing the bugs in the tracker. .SS "Contact" .IX Subsection "Contact" Please report any bugs or feature requests to \&\f(CW\*(C`bug\-anyevent\-feed at rt.cpan.org\*(C'\fR, or through the web interface at . I will be notified and then you'll automatically be notified of progress on your bug as I make changes. .SH "SUPPORT" .IX Header "SUPPORT" You can find documentation for this module with the perldoc command. .PP .Vb 1 \& perldoc AnyEvent::Feed .Ve .PP You can also look for information at: .IP "\(bu" 4 \&\s-1IRC:\s0 AnyEvent::Feed \s-1IRC\s0 Channel .Sp See the same channel as the AnyEvent::XMPP module: .Sp .Vb 3 \& IRC Network: http://freenode.net/ \& Server : chat.freenode.net \& Channel : #ae_xmpp \& \& Feel free to join and ask questions! .Ve .IP "\(bu" 4 AnnoCPAN: Annotated \s-1CPAN\s0 documentation .Sp .IP "\(bu" 4 \&\s-1CPAN\s0 Ratings .Sp .IP "\(bu" 4 \&\s-1RT: CPAN\s0's request tracker .Sp .IP "\(bu" 4 Search \s-1CPAN\s0 .Sp .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" Copyright 2009 Robin Redeker, all rights reserved. .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.