|
Revision 7781, 1.0 kB
(checked in by youpy, 9 months ago)
|
|
added plagger plugin: Subscription::Me
|
| Line | |
|---|
| 1 | package Plagger::Plugin::Subscription::Me; |
|---|
| 2 | use strict; |
|---|
| 3 | use base qw( Plagger::Plugin ); |
|---|
| 4 | |
|---|
| 5 | use Net::SocialGraph; |
|---|
| 6 | |
|---|
| 7 | sub register { |
|---|
| 8 | my($self, $context) = @_; |
|---|
| 9 | |
|---|
| 10 | $context->register_hook( |
|---|
| 11 | $self, |
|---|
| 12 | 'subscription.load' => $self->can('load'), |
|---|
| 13 | ); |
|---|
| 14 | } |
|---|
| 15 | |
|---|
| 16 | sub load { |
|---|
| 17 | my($self, $context) = @_; |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | my $sg = Net::SocialGraph->new(fme => 1); |
|---|
| 21 | my $res = $sg->get($self->conf->{url}); |
|---|
| 22 | |
|---|
| 23 | for my $node (keys(%{$res->{nodes}})) { |
|---|
| 24 | my $feed = Plagger::Feed->new; |
|---|
| 25 | $feed->url($node); |
|---|
| 26 | Plagger->context->subscription->add($feed); |
|---|
| 27 | } |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | 1; |
|---|
| 31 | |
|---|
| 32 | __END__ |
|---|
| 33 | |
|---|
| 34 | =head1 NAME |
|---|
| 35 | |
|---|
| 36 | Plagger::Plugin::Subscription::Me - Subscription list with Social Graph |
|---|
| 37 | |
|---|
| 38 | =head1 SYNOPSIS |
|---|
| 39 | |
|---|
| 40 | - module: Subscription::Me |
|---|
| 41 | config: |
|---|
| 42 | url: http://example.com/users/foo |
|---|
| 43 | |
|---|
| 44 | =head1 DESCRIPTION |
|---|
| 45 | |
|---|
| 46 | This plugin creates Subscription by fetching "me" links using Google |
|---|
| 47 | Social Graph API. |
|---|
| 48 | |
|---|
| 49 | =head1 AUTHOR |
|---|
| 50 | |
|---|
| 51 | youpy |
|---|
| 52 | |
|---|
| 53 | =head1 SEE ALSO |
|---|
| 54 | |
|---|
| 55 | L<Plagger>, L<http://code.google.com/apis/socialgraph/> |
|---|
| 56 | |
|---|
| 57 | =cut |
|---|