Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

PubSubHubbub subscriber implementation as a Plack App

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 example
Octocat-spinner-32 lib
Octocat-spinner-32 t
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Build.PL
Octocat-spinner-32 MANIFEST
Octocat-spinner-32 META.json
Octocat-spinner-32 META.yml
Octocat-spinner-32 Makefile.PL
Octocat-spinner-32 README
README
NAME
    Plack::App::PubSubHubbub::Subscriber - PubSubHubbub subscriber
    implementation as a Plack App

SYNOPSIS
     use Plack::Builder;
     use Plack::App::PubSubHubbub::Subscriber;
     use Plack::App::PubSubHubbub::Subscriber::Config;
     use Plack::App::PubSubHubbub::Subscriber::Client;

     my $conf = Plack::App::PubSubHubbub::Subscriber::Config->new(
         callback => "http://example.tld:8081/callback",
         lease_seconds => 86400,
         verify => 'sync',
     );

     my $app = Plack::App::PubSubHubbub::Subscriber->new(
         config => $conf
         on_verify => sub {
             my ($topic, $token, $mode, $lease) = @_;
             ...
             return 1;
         },
         on_ping => sub {
             my ($content_type, $content, $token) = @_;
             print $content;
         },
     );

     my $client = Plack::App::PubSubHubbub::Subscriber::Client(
         config => $conf,
     );

     builder {
         mount $app->callback_path, $app;
         mount '/subscribe' => sub {
             ...
             $client->subscribe( $hub, $topic, $token );
             ...
         };
         mount '/unsubscribe' => sub {
             ...
             $client->unsubscribe( $hub, $topic, $token );
             ...
         };
     };

DESCRIPTION
    PubSubHubbub subscriber implementation in the form of a Plack app and a
    client. Originally developed for storyfindr.com <http://storyfindr.com>

  $self->config( $conf )
    Get/Set the Plack::App::PubSubHubbub::Subscriber::Config object. This
    same config object can be use to instanciate the client
    Plack::App::PubSubHubbub::Subscriber::Client

  $self->on_ping( sub { my ($content_type, $content, $token) = @_ } )
    Triggered when a new ping is received, the parameters are the content
    type, the raw content, and the token in that order. Note that the token
    is available only if the configuration flag "token_in_path" is set (the
    default). Also note that, in any case, the token is undef if you didn't
    use a token to (un)subcribe. The return value is ignore.

  $self->on_verify( sub { my ($topic, $token, $mode, $lease) = @_ } )
    Triggered when a subscribe/unsubscribe request is received, the
    parameters are the topic, the token, the mode, and the number of seconds
    of the lease, in that order. Note that the token is undef if you didn't
    use a token to (un)subcribe. Given these parameters, this coderef must
    return 1 for verified, or 0 for rejected.

  $self->callback_path
    Return the path part of the callback URL. Useful for doing "mount
    $app->callback_path, $app;"

LIMITATION
    the "Authenticated Content Distribution" is not supported.

SEE ALSO
    the specs
    <http://pubsubhubbub.googlecode.com/svn/trunk/pubsubhubbub-core-0.3.html
    >, Net::PubSubHubbub::Publisher

AUTHOR
    Antoine Imbert, "<antoine.imbert at gmail.com>"

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

Something went wrong with that request. Please try again.