Simon Wistow > Net-Social-Service-Facebook-0.1 > Net::Social::Service::Facebook

Download:
Net-Social-Service-Facebook-0.1.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.1   Source  

NAME ^

Net::Social::Service::Facebook - a Facebook plugin for Net::Social

PARAMS ^

For reading Net::Social::Service::Facebook needs

api_key

You need an API key from Facebook. You can read how to get one from here

    http://developers.facebook.com/get_started.php
session_secret

See below.

session_key

See below.

GETTING A PERMANENT FACEBOOK SESSION ^

I use this script

    #!perl -w

    use strict;
    use WWW::Facebook::API;

    my $api_key        = shift || die "You must pass an api key\n"; # get these when you sign up
    my $secret         = shift || die "You must pass an api secret"; # as a facebook developer
    my $client         = make_client($api_key, $secret);

    # Now get the auth token
    print "1) Go to ".$client->get_infinite_session_url."\n";
    print "2) Press 'Generate' and get token\n";
    print "3) Enter the token now\n";
    chomp(my $token = <>);

    # Get a session
    $client->auth->get_session($token);
    $session_key    = $client->session_key;
    $session_secret = $client->secret;

    # And note the session key
    print "4) Your infinite session key is $session_key\n";
    print "5) Your infinite session secret is $session_secret\n";

    # Now make a new client and set the session key again to see that it works
    my $new_client = make_client($api_key, $session_secret);
    $new_client->session_key($session_key);

    # And get my friends
    my $friends = $new_client->users->get_info( uids => $new_client->friends->get, fields => 'name');
    print join("\n", map { $_->{name} } @$friends)."\n";

    sub make_client {
        my ($api_key, $secret) = @_;

        my $client = WWW::Facebook::API->new(
                parse        => 1,
                throw_errors => 1,
        );
        $client->api_key($api_key);
        $client->secret($secret);
        $client->desktop(1);
        return $client;
    }

METHODS ^

friends

Returns your friends. It defines the keys uid, name and type.

AUTHOR ^

Simon Wistow <simon@thegestalt.org>

COPYRIGHT ^

Copyright, 2007 - Simon Wistow

Distributed under the same terms as Perl itself

syntax highlighting: