LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 03-23-2013, 07:46 AM   #1
amboxer21
Member
 
Registered: Mar 2012
Location: New Jersey
Distribution: Linux Mint, Gentoo
Posts: 270

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

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"}]}
 
Old 03-28-2013, 04:47 AM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,630
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:

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


Reply


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 02:59 PM
Problems authenticating SSH session spangle1 Linux - Server 2 11-11-2011 04:00 AM
Perl NTLM authenticating module Jang217 Programming 1 11-11-2010 04:09 PM
SSH - trouble authenticating private/public key Micro420 Linux - Networking 5 01-23-2007 01:08 PM
Question regaurding dameons TL1moss Slackware 4 03-31-2005 09:28 AM


All times are GMT -5. The time now is 11:27 PM.

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