Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 03-23-2013, 08:46 AM   #1
Registered: Mar 2012
Location: New Jersey
Distribution: Gentoo
Posts: 291

Rep: Reputation: Disabled
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

#!/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   = '';
my $login_url = '';
#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 during REST friends.get call:
params = 
	api_key:hiding value for this post
	call_id:hiding value for this post.64725
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"}]}
Old 03-28-2013, 05:47 AM   #2
Senior Member
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 345Reputation: 345Reputation: 345Reputation: 345
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:

if ( $query->param('auth_token') ) {
    $fb->auth->get_session;( $query->param('auth_token') );
Does removing it fix the problem?


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl question (Facebook::Graph API) amboxer21 Programming 2 10-28-2012 03:59 PM
Problems authenticating SSH session spangle1 Linux - Server 2 11-11-2011 05:00 AM
Perl NTLM authenticating module Jang217 Programming 1 11-11-2010 05:09 PM
SSH - trouble authenticating private/public key Micro420 Linux - Networking 5 01-23-2007 02:08 PM
Question regaurding dameons TL1moss Slackware 4 03-31-2005 10:28 AM

All times are GMT -5. The time now is 02:54 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration