Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Use Facebook::Graph to write desktop application

Use Facebook::Graph to write desktop application

Topic: Use Facebook::Graph to write desktop application

Using Facebook::Graph Perl CPAN module to read/write data of Facebook.

Gea-Suan Lin

August 24, 2012
Tweet

More Decks by Gea-Suan Lin

Other Decks in Technology

Transcript

  1. Use Facebook::Graph to
    write desktop application
    Gea-Suan Lin

    View Slide

  2. Common $fb

    View Slide

  3. my $fb = Facebook::Graph->new(
    app_id => APP_ID,
    secret => SECRET,
    postback => ‘http://www.mysite.com/’
    );

    View Slide

  4. First to authorize

    View Slide

  5. my @perms =
    qw/publish_stream read_stream/;
    say $fb
    ->authorize
    ->extend_permission(@perms)
    ->uri_as_string;

    View Slide

  6. Open browser to
    authorize

    View Slide

  7. Then copy “code” value
    to the following code...

    View Slide

  8. my $r = $fb->
    request_access_token('*code*');
    say $r->token;

    View Slide

  9. You’ll get your token

    View Slide

  10. $fb->access_token($token);

    View Slide

  11. After authorizing...

    View Slide

  12. my $fb = Facebook::Graph->new(
    app_id => APP_ID,
    secret => SECRET,
    postback => ‘http://www.mysite.com/’
    );
    $fb->access_token($token);

    View Slide

  13. Then, post something...

    View Slide

  14. $fb
    ->add_post
    ->to(‘195466193802264’)
    ->set_message(‘test’)
    ->publish;

    View Slide

  15. And, read something...

    View Slide

  16. use Data::Dumper;
    print Dumper $fb->query
    ->find(‘195466193802264/feed’)
    ->request
    ->as_hashref;

    View Slide

  17. References

    View Slide

  18. Facebook::Graph
    http://goo.gl/Ym5KA

    View Slide

  19. Thanks !

    View Slide