line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Facebook; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Mojolicious::Plugin::Facebook - Interact with Mojo::Facebook |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
This module helps creating a L object. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
In C: |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub startup { |
16
|
|
|
|
|
|
|
my $self = shift; |
17
|
|
|
|
|
|
|
$self->plugin('Mojolicious::Plugin::Facebook', { |
18
|
|
|
|
|
|
|
app_namespace => '...', |
19
|
|
|
|
|
|
|
}); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
In a controller: |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub do_stuff { |
25
|
|
|
|
|
|
|
my $self = shift; |
26
|
|
|
|
|
|
|
my $token = '123456sdfgh98765'; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Mojo::IOLoop->delay( |
29
|
|
|
|
|
|
|
sub { |
30
|
|
|
|
|
|
|
my($delay) = @_; |
31
|
|
|
|
|
|
|
$self->facebook($token)->fetch({}, $delay->begin); |
32
|
|
|
|
|
|
|
}, |
33
|
|
|
|
|
|
|
sub { |
34
|
|
|
|
|
|
|
my($delay, $res) = @_; |
35
|
|
|
|
|
|
|
$self->render(json => $res); |
36
|
|
|
|
|
|
|
}, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
1
|
|
1102
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
43
|
1
|
|
|
1
|
|
771
|
use Mojo::Facebook; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
12
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 METHODS |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 register |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Will register the helper C. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub register { |
54
|
1
|
|
|
1
|
1
|
52
|
my($self, $app, $config) = @_; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
$app->helper(facebook => sub { |
57
|
1
|
|
|
1
|
|
46536
|
my $c = shift; |
58
|
1
|
50
|
33
|
|
|
2165
|
my %args = (@_ == 1 and ref $_[0] eq '') ? (access_token => shift) : @_; |
59
|
1
|
50
|
|
|
|
9
|
$args{app_namespace} = $config->{app_namespace} if $config->{app_namespace}; |
60
|
1
|
|
|
|
|
9
|
$args{scheme} = $c->req->url->to_abs->scheme; |
61
|
1
|
|
|
|
|
1076
|
$c->stash->{'mojo.plugin.facebook'} = Mojo::Facebook->new(%args); |
62
|
1
|
|
|
|
|
13
|
}); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
See L. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 AUTHOR |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
See L. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |