| 1 | package Facebook::Graph::Page::Feed; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 4 | $Facebook::Graph::Page::Feed::VERSION = '1.1101'; | |||||||||||||||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 4 | $Facebook::Graph::Page::Feed::VERSION = '1.0700'; | |||||||||||||||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 4 | extends 'Facebook::Graph::Publish'; | |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | has page_id => ( | |||||||||||||||||||||||||||||||||||||||||
| 9 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 10 | predicate => 'has_page_id', | ||||||||||||||||||||||||||||||||||||||||||
| 11 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | sub set_page_id { | ||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | my ($self, $page_id) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_page_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | $self->object_name(''); # not sure it's a good way here | |||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | $self->set_published(1); # it's a default value on FB side; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | $self->page_id($page_id); | |||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 4 | ▶ | use subs qw(object_path); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | sub object_path{ | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | my $s = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
object_path: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | return $s->has_page_id ? | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | sprintf( '%s/feed', $s->page_id ) | ||||||||||||||||||||||||||||||||||||||||||
| 27 | : die "You must set_page_id first"; | ||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 4 | has message => ( | |||||||||||||||||||||||||||||||||||||||||
| 31 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 32 | predicate => 'has_message', | ||||||||||||||||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | sub set_message { | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | my ($self, $message) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_message: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | $self->message($message); | |||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 4 | has link_uri => ( | |||||||||||||||||||||||||||||||||||||||||
| 42 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 43 | predicate => 'has_link_uri', | ||||||||||||||||||||||||||||||||||||||||||
| 44 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | sub set_link_uri { | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | my ($self, $link_uri) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_link_uri: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $self->link_uri($link_uri); | |||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 4 | has backdated_time => ( | |||||||||||||||||||||||||||||||||||||||||
| 53 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 54 | predicate => 'has_backdated_time', | ||||||||||||||||||||||||||||||||||||||||||
| 55 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | sub set_backdated_time | ||||||||||||||||||||||||||||||||||||||||||
| 58 | { | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | my ($self, $backdated_time) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_backdated_time: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | $self->backdated_time($backdated_time); | |||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 4 | has scheduled_publish_time => ( | |||||||||||||||||||||||||||||||||||||||||
| 65 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 66 | predicate => 'has_scheduled_publish_time' | ||||||||||||||||||||||||||||||||||||||||||
| 67 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | sub set_scheduled_publish_time | ||||||||||||||||||||||||||||||||||||||||||
| 70 | { | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | my ($self, $scheduled_publish_time) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_scheduled_publish_time: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | $self->scheduled_publish_time($scheduled_publish_time); | |||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 4 | has published => ( | |||||||||||||||||||||||||||||||||||||||||
| 77 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 78 | predicate => 'has_published', | ||||||||||||||||||||||||||||||||||||||||||
| 79 | reader => '_get_published', | ||||||||||||||||||||||||||||||||||||||||||
| 80 | writer => '_set_published', | ||||||||||||||||||||||||||||||||||||||||||
| 81 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | sub published | ||||||||||||||||||||||||||||||||||||||||||
| 84 | { | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | my($self, $published) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
published: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | if( scalar @_ > 1 ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | { | ||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $self->_set_published($published); | |||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | return $self->_get_published && $self->_get_published ne 'false'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->_get_published && $self->_get_published ne 'false'
MC/DC0%0/2
$self->_get_published && $self->_get_published ne 'false'
$self->_get_published
$self->_get_published ne 'false'
Truth table0%0/3
A && B
A= $self->_get_publishedB= $self->_get_published ne 'false'
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | sub set_published | ||||||||||||||||||||||||||||||||||||||||||
| 96 | { | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | my ($self, $published) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_published: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | $self->published($published); | |||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | around get_post_params => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | my ($orig, $self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my $post = $orig->($self); | |||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | if ($self->has_message) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | push @$post, message => $self->message; | |||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | if ($self->has_link_uri) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | push @$post, link => $self->link_uri; | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | if ($self->has_backdated_time) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | push @$post, backdated_time => $self->backdated_time + 10*3600; # temporary fix for FB::Graph API | |||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$self->has_scheduled_publish_time and not $self->has_published && $self->published
$self->has_published && $self->published
MC/DC0%0/3
$self->has_scheduled_publish_time and not $self->has_published && $self->published
$self->has_scheduled_publish_time
$self->has_published
$self->published
Truth table0%0/4
A and not(B && C)
A= $self->has_scheduled_publish_timeB= $self->has_publishedC= $self->published
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | $self->has_scheduled_publish_time | ||||||||||||||||||||||||||||||||||||||||||
| 116 | and ( | ||||||||||||||||||||||||||||||||||||||||||
| 117 | not $self->has_published or not $self->published | ||||||||||||||||||||||||||||||||||||||||||
| 118 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 119 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | push @$post, scheduled_publish_time => $self->scheduled_publish_time; | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | if ($self->has_published) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | push @$post, published => $self->published ? 'true': 'false'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | return $post; | |||||||||||||||||||||||||||||||||||||||||
| 126 | 4 | }; | |||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | Facebook::Graph::Page::Feed - Add a post to a Facebook page. | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | version 1.1101 | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | my $fb = Facebook::Graph->new; | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | $fb->add_page_feed | ||||||||||||||||||||||||||||||||||||||||||
| 143 | ->set_page_id($page_id) | ||||||||||||||||||||||||||||||||||||||||||
| 144 | ->set_message('This is a test post') | ||||||||||||||||||||||||||||||||||||||||||
| 145 | ->set_backdated_time(time-3600) | ||||||||||||||||||||||||||||||||||||||||||
| 146 | ->set_scheduled_publish_time(time+3600) | ||||||||||||||||||||||||||||||||||||||||||
| 147 | ->set_published('false') | ||||||||||||||||||||||||||||||||||||||||||
| 148 | ->set_link_uri('http://mysite.com/testpage') | ||||||||||||||||||||||||||||||||||||||||||
| 149 | ->publish; | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | This module gives you quick and easy access to publish posts on FB pages. | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | Implements publishing protocol available here: | ||||||||||||||||||||||||||||||||||||||||||
| 157 | L<https://developers.facebook.com/docs/graph-api/reference/v2.0/page/feed/> | ||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | B<ATTENTION:> You must have the page access token to use this module. | ||||||||||||||||||||||||||||||||||||||||||
| 160 | It's available in C<$fb->fetch('me/accounts')>, but, you must have a user | ||||||||||||||||||||||||||||||||||||||||||
| 161 | token with C<manage_page> permission. | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | More information about tokens could be found here: | ||||||||||||||||||||||||||||||||||||||||||
| 164 | L<https://developers.facebook.com/docs/facebook-login/access-tokens> | ||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | =head2 set_page_id ( page_id ) | ||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | Specify a page id to post to. This is required field and must be set before | ||||||||||||||||||||||||||||||||||||||||||
| 171 | publishing. | ||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | =head2 set_message ( message ) | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | Sets the description of the link. | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | =head3 message | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | A string of text. | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | =head2 set_link_uri ( uri ) | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | Sets the URI to link to. | ||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | =head3 uri | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | A URI. | ||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | =head2 set_backdated_time ( time ) | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | Set a date of your post, different from now. Just a backdate. Time should be a | ||||||||||||||||||||||||||||||||||||||||||
| 193 | timestamp, no fancy formats. | ||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | =head2 set_scheduled_publish_time( time ) | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | Set a publishing time for scheduled posts. Time should be a desired timestamp of | ||||||||||||||||||||||||||||||||||||||||||
| 198 | post in future. Doesn't work with minutes from now, but works fine with hour+ | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | =head2 publish ( ) | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | Posts the data and returns a L<Facebook::Graph::Response> object. The response object should contain the id: | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | {"id":"1647395831_130068550371568"} | ||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | =head1 LEGAL | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | Facebook::Graph is Copyright 2010 - 2012 Plain Black Corporation (L<http://www.plainblack.com>) and is licensed under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | Facebook::Graph::Page::Feed is Copyright 2014 Alexandr Evstigneev (L<http://evstigneev.com>) and is licensed under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | =cut | ||||||||||||||||||||||||||||||||||||||||||