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


Manual Reference Pages  -  FACEBOOK::GRAPH::COOKBOOK::RECIPE3 (3)

.ds Aq ’

NAME

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

CONTENTS

VERSION

version 1.0801

DESCRIPTION

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

    Assumptions

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.

RECIPE



 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, "Couldnt 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};



SEE ALSO

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

LEGAL

Facebook::Graph is Copyright 2010 - 2012 Plain Black Corporation (<http://www.plainblack.com>) and is licensed under the same terms as Perl itself.
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 FACEBOOK::GRAPH::COOKBOOK::RECIPE3 (3) 2014-09-08

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