GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Facebook::Graph::Cookbook::Recipe3(3) User Contributed Perl Documentation Facebook::Graph::Cookbook::Recipe3(3)

Facebook::Graph::Cookbook::Recipe3 - Impersonation

version 1.0801

Building an application that can post as another page under my control.

We're assuming you've already learned the basics of Facebook::Graph through the other recipes and have already set up your application access token.

 use Facebook::Graph;
 use Ouch;
 use Config::JSON;

 # init
 my $fb_config = Config::JSON->new('/path/to/my.conf')->get('facebook');
 my $fb = Facebook::Graph->new($fb_config);

 # get list of available my pages and access tokens
 my $pages = $fb->query->find('me/accounts')->include_metadata->request->as_hashref->{data};
 my $token;

 # identify the specific page i want to post to
 foreach my $page (@{$pages}) {
     $token = $page->{access_token} if $page->{id} eq $fb_config->{page_id};
 }   
 unless (defined $token) {
     ouch 504, "Couldn't post to Facebook.";
 }   

 # post
 $fb->access_token($token);
 my $response_id = $fb->add_post
     ->set_message($message);
     ->set_link_name($link_name)
     ->set_link_uri($link_uri)
     ->set_link_description($link_description)
     ->set_picture_uri($picture_uri)
     ->publish
     ->as_hashref
     ->{id};

For more recipes, check out the Facebook::Graph::Cookbook.

Facebook::Graph is Copyright 2010 - 2012 Plain Black Corporation (<http://www.plainblack.com>) and is licensed under the same terms as Perl itself.
2014-09-08 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.