LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Perl question regaurding authenticating facebook. Missing session key (http://www.linuxquestions.org/questions/programming-9/perl-question-regaurding-authenticating-facebook-missing-session-key-4175455240/)

amboxer21 03-23-2013 08:46 AM

Perl question regaurding authenticating facebook. Missing session key
 
A few days ago I decided to pick Perl back up and have another crack at the Facebook API. I am having trouble finding documentation that is elaborate enough for me to comprehend. Which I have come up with nothing so far. There is a great Perl module on cpan but the doc is kind of ambiguous imo. There are not many example that I can follow. Most of the code, doc, and/or examples pertain to Javascript or Java. Maybe someone here who has worked with Facebook's API or is able to figure it out, could help me out. I would greatly appreciate it!

Here is the code

Code:

#!/usr/bin/perl -w

use strict;

use URI;
use CGI::Simple;
use Data::Dumper;
use WWW::Facebook::API;

my $app_id = 'My app id';
my $app_secret = 'My app secret';

my $query = CGI::Simple->new;

my $fb = WWW::Facebook::API->new(
        desktop                => 1,
        api_key                => $app_id,
        secret                => $app_secret,
        );

#my $query  = CGI::Simple->new;
#my $params = $query->param('auth_token');

my $access_token = $fb->auth->create_token;
#$fb->auth->get_session( $access_token );

        if ( $query->param('auth_token') ) {
        $fb->auth->get_session;( $query->param('auth_token') );
        }

my $sleep      = 15;
my $browser_cmd = 'chromium-browser';
#my $login_url  = 'https://www.facebook.com/login.php?';
my $login_url = 'https://peaceful-dawn-6605.herokuapp.com';
#my $browser_cmd = '/opt/google/chrome/chrome';

#$fb->auth->login( sleep => $sleep , browser => $browser_cmd );
system qq($browser_cmd "$login_url");

my $friends = $fb->friends->get;
print Dumper $friends;

The REST call for authentication gives no errors. It's during the get friends call where I am recieving erros. Saying i am missing a session key.

ERROR
Code:

Error during REST friends.get call:
params =
        api_key:hiding value for this post
        call_id:hiding value for this post.64725
        format:JSON
        method:facebook.friends.get
        session_key:
        v:1.0
response =
{"error_code":102,"error_msg":"parameters uid or session key required","request_args":[{"key":"api_key","value":"hiding value for this post"},{"key":"call_id","value":"hiding value for this post"},{"key":"format","value":"JSON"},{"key":"method","value":"facebook.friends.get"},{"key":"session_key","value":""},{"key":"v","value":"1.0"},{"key":"sig","value":"hiding value for this post"}]}


Snark1994 03-28-2013 05:47 AM

I don't know much about the FB API (or perl for that matter) but I think you've got an extraneous semi-colon on your "get_session" line:

Code:

if ( $query->param('auth_token') ) {
    $fb->auth->get_session;( $query->param('auth_token') );
}

Does removing it fix the problem?


All times are GMT -5. The time now is 08:34 AM.