[cfca761] | 1 | package Facebook::Graph::Publish::Note; |
---|
| 2 | BEGIN { |
---|
| 3 | $Facebook::Graph::Publish::Note::VERSION = '1.0300'; |
---|
| 4 | } |
---|
| 5 | |
---|
| 6 | use Any::Moose; |
---|
| 7 | extends 'Facebook::Graph::Publish'; |
---|
| 8 | |
---|
| 9 | use constant object_path => '/notes'; |
---|
| 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 subject => ( |
---|
| 23 | is => 'rw', |
---|
| 24 | predicate => 'has_subject', |
---|
| 25 | ); |
---|
| 26 | |
---|
| 27 | sub set_subject { |
---|
| 28 | my ($self, $subject) = @_; |
---|
| 29 | $self->subject($subject); |
---|
| 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_subject) { |
---|
| 42 | push @$post, subject => $self->subject; |
---|
| 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::Note - Add a note to a user's list of notes. |
---|
| 55 | |
---|
| 56 | =head1 VERSION |
---|
| 57 | |
---|
| 58 | version 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 | |
---|
| 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 body text of the note. |
---|
| 86 | |
---|
| 87 | =head3 message |
---|
| 88 | |
---|
| 89 | A string of text. |
---|
| 90 | |
---|
| 91 | |
---|
| 92 | =head2 set_subject ( subject ) |
---|
| 93 | |
---|
| 94 | Sets the title to identify the note from others. |
---|
| 95 | |
---|
| 96 | =head3 subject |
---|
| 97 | |
---|
| 98 | A string of text. |
---|
| 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 |
---|