Topic: Use Facebook::Graph to write desktop application
Using Facebook::Graph Perl CPAN module to read/write data of Facebook.
Use Facebook::Graph towrite desktop applicationGea-Suan Lin
View Slide
Common $fb
my $fb = Facebook::Graph->new(app_id => APP_ID,secret => SECRET,postback => ‘http://www.mysite.com/’);
First to authorize
my @perms =qw/publish_stream read_stream/;say $fb->authorize->extend_permission(@perms)->uri_as_string;
Open browser toauthorize
Then copy “code” valueto the following code...
my $r = $fb->request_access_token('*code*');say $r->token;
You’ll get your token
$fb->access_token($token);
After authorizing...
my $fb = Facebook::Graph->new(app_id => APP_ID,secret => SECRET,postback => ‘http://www.mysite.com/’);$fb->access_token($token);
Then, post something...
$fb->add_post->to(‘195466193802264’)->set_message(‘test’)->publish;
And, read something...
use Data::Dumper;print Dumper $fb->query->find(‘195466193802264/feed’)->request->as_hashref;
References
Facebook::Graphhttp://goo.gl/Ym5KA
Thanks !