source: perl/modules/Facebook/lib/Facebook/Graph/Publish/Note.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: 2.0 KB
Line 
1package Facebook::Graph::Publish::Note;
2BEGIN {
3  $Facebook::Graph::Publish::Note::VERSION = '1.0300';
4}
5
6use Any::Moose;
7extends 'Facebook::Graph::Publish';
8
9use constant object_path => '/notes';
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 subject => (
23    is          => 'rw',
24    predicate   => 'has_subject',
25);
26
27sub set_subject {
28    my ($self, $subject) = @_;
29    $self->subject($subject);
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_subject) {
42        push @$post, subject => $self->subject;
43    }
44    return $post;
45};
46
47
48no Any::Moose;
49__PACKAGE__->meta->make_immutable;
50
51
52=head1 NAME
53
54Facebook::Graph::Publish::Note - Add a note to a user's list of notes.
55
56=head1 VERSION
57
58version 1.0300
59
60=head1 SYNOPSIS
61
62 my $fb = Facebook::Graph->new;
63
64 $fb->add_note
65    ->set_subject('Things I Like')
66    ->set_message('I like beer.')
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 body text of the note.
86
87=head3 message
88
89A string of text.
90
91
92=head2 set_subject ( subject )
93
94Sets the title to identify the note from others.
95
96=head3 subject
97
98A string of text.
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.