NAME
Facebook::Graph::Publish::Post - Publish to a user's wall.
VERSION
version 1.1201
SYNOPSIS
my $fb = Facebook::Graph->new;
$fb->add_post
->set_message('I like beer.')
->publish;
my $response = $fb->add_post
->set_message('I like Perl.')
->set_picture_uri('http://www.perl.org/i/camel_head.png')
->set_link_uri('http://www.perl.org/')
->set_link_name('Perl.org')
->set_link_caption('Perl is a programming language.')
->set_link_description('A link to the Perl web site.')
->publish;
DESCRIPTION
This module gives you quick and easy access to publish to a user's Facebook feed.
ATTENTION: You must have the publish_stream
privilege to use this module.
TIP: Facebook seems to use these terms interchangeably: Feed, Post, News, Wall. So if you want to publish to a user's wall, this is the mechanism you use to do that.
METHODS
to ( id )
Specify a profile id to post to. Defaults to 'me', which is the currently logged in user.
set_message ( message )
Sets the text to post to the wall.
message
A string of text.
set_picture_uri ( uri )
Sets the URI of a picture to be displayed in the message.
uri
A URI to a picture.
set_link_uri ( uri )
Sets the URI of a link that viewers can click on for more information about whatever you posted in set_message
.
uri
A URI to a site.
set_link_name ( name )
If you want to give the link you set in set_link_uri
a human friendly name, use this method.
name
A text string to be used as the name of the link.
set_link_caption ( caption )
Sets a short blurb to be displayed below the link/picture.
caption
A text string.
set_link_description ( description )
Sets a longer description of the site you're linking to. Can also be a portion of the article you're linking to.
description
A text string.
set_source ( uri )
Sets a source URI for a flash or video file.
uri
The URI you wish to set. For example if you wanted to include a YouTube video:
$post->set_source('http://www.youtube.com/watch?v=efsJRdJ6dog');
set_actions ( actions )
Sets a list of actions (or links) that should go in the post as things people can do with the post. This allows for integration of the post with third party sites.
actions
An array reference of hash references containing name
/ link
pairs.
$post->actions([
{
name => 'Click Me!',
link => 'http://www.somesite.com/click',
},
...
]);
add_action ( name, link )
Adds an action to the list of actions set either by previously calling add_action
or by calling set_actions
.
name
The name of the action (the clickable label).
link
The URI of the action.
set_privacy ( setting, options )
A completely optional privacy setting.
set_properties ( properties )
"property" values assigned when the post is published. This is typically rendered as a list of links.
$post->set_properties( { "search engine:" => { "text" => "Google", "href" => "http://www.google.com/" } } );
setting
The privacy setting. Choose from: EVERYONE, CUSTOM, ALL_FRIENDS, NETWORKS_FRIENDS, and FRIENDS_OF_FRIENDS. See http://developers.facebook.com/docs/reference/api/post for changes in this list.
options
A hash reference of options to tweak the privacy setting. Some options are required depending on what privacy setting you chose. See http://developers.facebook.com/docs/reference/api/post for details.
$post->set_privacy('CUSTOM', { friends => 'SOME_FRIENDS', allow => [qw( 119393 993322 )] });
- friends
-
A string that must be one of EVERYONE, NETWORKS_FRIENDS, FRIENDS_OF_FRIENDS, ALL_FRIENDS, SOME_FRIENDS, SELF, or NO_FRIENDS.
- networks
-
An array reference of network ids.
- allow
-
An array reference of user ids.
- deny.
-
An array reference of user ids.
set_target_countries ( countries )
Makes a post only available to viewers in certain countries.
$post->set_target_countries( ['US'] );
countries
An array reference of two letter country codes (upper case). You can find a list of country codes in the list of city ids here: http://developers.facebook.com/attachment/all_cities_final.csv.
set_target_regions ( regions )
Makes a post only available to viewers in certain regions.
$post->set_target_regions( [6,53] );
regions
An array reference of region numbers however Facebook defines that. I've got no idea because their documentation sucks. I'm not even sure what a region is. Is it a region of a country? Of a continent? No idea. I do know it is an integer, but that's about it.
set_target_cities ( cities )
Makes a post only available to viewers in certain cities.
$post->set_target_cities( [2547804] );
cities
An array reference of cities ids. In the example above I've listed Madison, WI. You can find a list of their cities here: http://developers.facebook.com/attachment/all_cities_final.csv
set_target_locales ( locales )
Makes a post only available to viewers in certain locales.
$post->set_target_locales( [6] );
locales
An array reference of locales ids. You can find their list of locales here: http://developers.facebook.com/attachment/locales_final.csv
publish ( )
Posts the data and returns a Facebook::Graph::Response object. The response object should contain the id:
{"id":"1647395831_130068550371568"}
LEGAL
Facebook::Graph is Copyright 2010 - 2012 Plain Black Corporation (http://www.plainblack.com) and is licensed under the same terms as Perl itself.