1 | package Facebook::Graph::Publish::Link; |
---|
2 | BEGIN { |
---|
3 | $Facebook::Graph::Publish::Link::VERSION = '1.0300'; |
---|
4 | } |
---|
5 | |
---|
6 | use Any::Moose; |
---|
7 | extends 'Facebook::Graph::Publish'; |
---|
8 | |
---|
9 | use constant object_path => '/links'; |
---|
10 | |
---|
11 | has message => ( |
---|
12 | is => 'rw', |
---|
13 | predicate => 'has_message', |
---|
14 | ); |
---|
15 | |
---|
16 | sub set_message { |
---|
17 | my ($self, $message) = @_; |
---|
18 | $self->message($message); |
---|
19 | return $self; |
---|
20 | } |
---|
21 | |
---|
22 | has link_uri => ( |
---|
23 | is => 'rw', |
---|
24 | predicate => 'has_link_uri', |
---|
25 | ); |
---|
26 | |
---|
27 | sub set_link_uri { |
---|
28 | my ($self, $link_uri) = @_; |
---|
29 | $self->link_uri($link_uri); |
---|
30 | return $self; |
---|
31 | } |
---|
32 | |
---|
33 | |
---|
34 | |
---|
35 | around get_post_params => sub { |
---|
36 | my ($orig, $self) = @_; |
---|
37 | my $post = $orig->($self); |
---|
38 | if ($self->has_message) { |
---|
39 | push @$post, message => $self->message; |
---|
40 | } |
---|
41 | if ($self->has_link_uri) { |
---|
42 | push @$post, link => $self->link_uri; |
---|
43 | } |
---|
44 | return $post; |
---|
45 | }; |
---|
46 | |
---|
47 | |
---|
48 | no Any::Moose; |
---|
49 | __PACKAGE__->meta->make_immutable; |
---|
50 | |
---|
51 | |
---|
52 | =head1 NAME |
---|
53 | |
---|
54 | Facebook::Graph::Publish::Link - Add a link. |
---|
55 | |
---|
56 | =head1 VERSION |
---|
57 | |
---|
58 | version 1.0300 |
---|
59 | |
---|
60 | =head1 SYNOPSIS |
---|
61 | |
---|
62 | my $fb = Facebook::Graph->new; |
---|
63 | |
---|
64 | $fb->add_link |
---|
65 | ->set_link_uri('http://www.plainblack.com') |
---|
66 | ->set_message('Plain Black') |
---|
67 | ->publish; |
---|
68 | |
---|
69 | |
---|
70 | =head1 DESCRIPTION |
---|
71 | |
---|
72 | This module gives you quick and easy access to publish notes. |
---|
73 | |
---|
74 | B<ATTENTION:> You must have the C<publish_stream> privilege to use this module. |
---|
75 | |
---|
76 | =head1 METHODS |
---|
77 | |
---|
78 | =head2 to ( id ) |
---|
79 | |
---|
80 | Specify a profile id to post to. Defaults to 'me', which is the currently logged in user. |
---|
81 | |
---|
82 | |
---|
83 | =head2 set_message ( message ) |
---|
84 | |
---|
85 | Sets the description of the link. |
---|
86 | |
---|
87 | =head3 message |
---|
88 | |
---|
89 | A string of text. |
---|
90 | |
---|
91 | |
---|
92 | =head2 set_link_uri ( uri ) |
---|
93 | |
---|
94 | Sets the URI to link to. |
---|
95 | |
---|
96 | =head3 uri |
---|
97 | |
---|
98 | A a URI. |
---|
99 | |
---|
100 | |
---|
101 | |
---|
102 | =head2 publish ( ) |
---|
103 | |
---|
104 | Posts the data and returns a L<Facebook::Graph::Response> object. The response object should contain the id: |
---|
105 | |
---|
106 | {"id":"1647395831_130068550371568"} |
---|
107 | |
---|
108 | =head1 LEGAL |
---|
109 | |
---|
110 | Facebook::Graph is Copyright 2010 Plain Black Corporation (L<http://www.plainblack.com>) and is licensed under the same terms as Perl itself. |
---|
111 | |
---|
112 | =cut |
---|