source: perl/modules/Facebook/lib/Facebook/Graph/Publish/Link.pm

release-1.10release-1.9
Last change on this file was 2a42248, checked in by Edward Z. Yang <ezyang@mit.edu>, 13 years ago
Add vanilla Facebook::Graph. Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
  • Property mode set to 100644
File size: 1.9 KB
Line 
1package Facebook::Graph::Publish::Link;
2BEGIN {
3  $Facebook::Graph::Publish::Link::VERSION = '1.0300';
4}
5
6use Any::Moose;
7extends 'Facebook::Graph::Publish';
8
9use constant object_path => '/links';
10
11has message => (
12    is          => 'rw',
13    predicate   => 'has_message',
14);
15
16sub set_message {
17    my ($self, $message) = @_;
18    $self->message($message);
19    return $self;
20}
21
22has link_uri => (
23    is          => 'rw',
24    predicate   => 'has_link_uri',
25);
26
27sub set_link_uri {
28    my ($self, $link_uri) = @_;
29    $self->link_uri($link_uri);
30    return $self;
31}
32
33
34
35around 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
48no Any::Moose;
49__PACKAGE__->meta->make_immutable;
50
51
52=head1 NAME
53
54Facebook::Graph::Publish::Link - Add a link.
55
56=head1 VERSION
57
58version 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
72This module gives you quick and easy access to publish notes.
73
74B<ATTENTION:> You must have the C<publish_stream> privilege to use this module.
75
76=head1 METHODS
77
78=head2 to ( id )
79
80Specify a profile id to post to. Defaults to 'me', which is the currently logged in user.
81
82
83=head2 set_message ( message )
84
85Sets the description of the link.
86
87=head3 message
88
89A string of text.
90
91
92=head2 set_link_uri ( uri )
93
94Sets the URI to link to.
95
96=head3 uri
97
98A a URI.
99
100
101
102=head2 publish ( )
103
104Posts 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
110Facebook::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
Note: See TracBrowser for help on using the repository browser.