AnyEvent-Superfeedr
view release on metacpan or search on metacpan
lib/AnyEvent/Superfeedr.pm view on Meta::CPAN
my $superfeedr = shift;
return $superfeedr->{xmpp_pubsub};
}
sub xmpp_connection {
my $superfeedr = shift;
my $con = $superfeedr->{xmpp_connection};
return $con if $con;
my $client = $superfeedr->{xmpp_client} or return;
my $jid = $superfeedr->{jid};
my $account = $client->get_account($jid) or return;
$con = $account->connection;
$superfeedr->{xmpp_connection} = $con;
return $con;
}
1;
__END__
=encoding utf-8
=for stopwords
=head1 NAME
AnyEvent::Superfeedr - XMPP interface to Superfeedr service.
=head1 SYNOPSIS
use AnyEvent::Superfeedr;
my $callback = sub {
my AnyEvent::Superfeedr::Notification $notification = shift;
my $feed_uri = $notification->feed_uri;
my $http_status = $notification->http_status;
my $next_fetch = $notification->next_fetch;
printf "status %s for %s. next: %s\n",
$http_status, $feed_uri, $next_fetch;
for my XML::Atom::Entry $entry ($notification->entries) {
printf "Got: %s\n" $entry->title;
}
};
my $superfeedr = AnyEvent::Superfeedr->new(
jid => $jid,
password => $password
on_notification => $callback,
);
$superfeedr->connect;
AnyEvent->condvar->recv;
# Subsribe upon connection
my $superfeedr = AnyEvent::Superfeedr->new(
jid => $jid,
password => $password,
);
$superfeedr->connect(sub { $superfeedr->subscribe($feed_uri) });
# Periodically fetch new URLs from database and subscribe
my $timer = AnyEvent->timer(
after => 5,
interval => 5 * 60,
cb => sub {
my @new_feeds = get_new_feeds_from_database() or return;
$superfeedr->subscribe(@new_feeds);
},
);
$end->recv;
=head1 DESCRIPTION
WARNING: the interface is likely to change in the future.
Allows you to subscribe to feeds and get notified real-time about new
content.
This is a first version of the api, and probably only covers specific
architectural needs.
=head1 EXAMPLES
see in the eg/ directory of the distribution.
=head1 AUTHOR
Yann Kerherve E<lt>yannk@cpan.orgE<gt>
=head1 CONTRIBUTORS
Tatsuhiko Miyagawa E<lt>miyagawa@bulknews.netE<gt>
=head1 LICENSE
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=head1 SEE ALSO
L<AnyEvent::XMPP> L<AnyEvent> L<http://superfeedr.com>
=cut
( run in 1.040 second using v1.01-cache-2.11-cpan-39bf76dae61 )