Skip Menu |

This queue is for tickets about the WWW-Facebook-API CPAN distribution.

Report information
The Basics
Id: 43972
Status: resolved
Priority: 0/
Queue: WWW-Facebook-API

People
Owner: Nobody in particular
Requestors: JEFFA [...] cpan.org
Cc: jeffa [...] shutterstock.com
AdminCc:

Bug Information
Severity: Unimportant
Broken in: (no value)
Fixed in: (no value)



CC: jeffa [...] shutterstock.com
Subject: Possible bug -- but could be my misunderstanding
Greetings! I am trying to use WWW::Facebook::API and i cannot seem to even get to first base with it. Here is my sample code: ============================================ use strict; use warnings; use WWW::Facebook::API; my $api = WWW::Facebook::API->new( desktop => 1, app_id => 'yes this is my correct app id', api_key => 'yes this is my correct api key', secret => 'yes this is my correct secret key', ); $api->auth->get_session( $api->auth->create_token ); ============================================ I have verified my various keys and they are correct, however when this code is run Facebook returns the following error: ============================================ Error during REST auth.getSession call: params = api_key:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX auth_token:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX call_id:1236621974.82341 format:JSON method:facebook.auth.getSession v:1.0 response = {"error_code":100,"error_msg":"Invalid parameter","request_args":[{"key":"api_key","value":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"},{"key":"auth_token","value":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"},{"key":"call_id","value":"1236621974.82341"},{"key":"format","value":"JSON"},{"key":"method","value":"facebook.auth.getSession"},{"key":"v","value":"1.0"},{"key":"sig","value":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}]} at /usr/lib/perl5/site_perl/5.8.8/WWW/Facebook/API.pm line 212 ============================================ I am stumped and perplexed. The only clue that Facebook discloses is that there is an "Invalid parameter" ... which could be anything. My inclination is to believe that they changed their API and WWW::Facebook::API is not up to date, but it seems more likely that i am not using the module correctly. Some more examples in the docs would be helpful. Like maybe a cookbook. :) Any help you can offer would be splendid. Thanks in advance.
Subject: Re: [rt.cpan.org #43972] Possible bug -- but could be my misunderstanding
Date: Mon, 9 Mar 2009 15:32:56 -0400
To: bug-WWW-Facebook-API [...] rt.cpan.org
From: Clayton Scott <clayton.scott [...] gmail.com>
This may have to do with it being a desktop app. I've never built one before, only we apps. I'll try to have a poke at this tonight and see if I can help you out. Clayton On Mon, Mar 9, 2009 at 2:24 PM, JEFFA via RT <bug-WWW-Facebook-API@rt.cpan.org> wrote: Show quoted text
> Mon Mar 09 14:24:27 2009: Request 43972 was acted upon. > Transaction: Ticket created by JEFFA >       Queue: WWW-Facebook-API >     Subject: Possible bug -- but could be my misunderstanding >   Broken in: (no value) >    Severity: Unimportant >       Owner: Nobody >  Requestors: JEFFA@cpan.org >      Status: new >  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=43972 > > > > Greetings! > > I am trying to use WWW::Facebook::API and i cannot seem to even get to > first base with it. Here is my sample code: > > ============================================ > use strict; > use warnings; > > use WWW::Facebook::API; > > my $api = WWW::Facebook::API->new( >    desktop => 1, >    app_id  => 'yes this is my correct app id', >    api_key => 'yes this is my correct api key', >    secret  => 'yes this is my correct secret key', > ); > > $api->auth->get_session( $api->auth->create_token ); > ============================================ > > I have verified my various keys and they are correct, however when this > code is run Facebook returns the following error: > > > ============================================ > Error during REST auth.getSession call: > params = > api_key:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > auth_token:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > call_id:1236621974.82341 > format:JSON > method:facebook.auth.getSession > v:1.0 > response = > {"error_code":100,"error_msg":"Invalid > parameter","request_args":[{"key":"api_key","value":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"},{"key":"auth_token","value":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"},{"key":"call_id","value":"1236621974.82341"},{"key":"format","value":"JSON"},{"key":"method","value":"facebook.auth.getSession"},{"key":"v","value":"1.0"},{"key":"sig","value":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}]} > at /usr/lib/perl5/site_perl/5.8.8/WWW/Facebook/API.pm line 212 > ============================================ > > I am stumped and perplexed. The only clue that Facebook discloses is > that there is an "Invalid parameter" ... which could be anything. My > inclination is to believe that they changed their API and > WWW::Facebook::API is not up to date, but it seems more likely that i am > not using the module correctly. Some more examples in the docs would be > helpful. Like maybe a cookbook. :) > > Any help you can offer would be splendid. Thanks in advance. >
-- Clayton Scott clayton.scott@gmail.com
Thanks for the super speedy reply. :) FWIW, i really am not planning on using a desktop app, i simply was trying to isolate the issue. I am trying to get a list of my friends from the API and i really just don't understand the steps needed to do so. Here is my code: ============================================ my $api = WWW::Facebook::API->new( desktop => 0, app_id => 'XXXXXXXXXX', api_key => 'XXXXXXXXXX', secret => 'XXXXXXXXXX', ); my $auth_token = param( 'fb_sig_session_key' ); $api->auth->get_session( $auth_token ); ============================================ And i get the same error: "error_code":100,"error_msg":"Invalid parameter" If i do not call get_session() and try to simply call friends->get() then i receive the error: "error_code":102,"error_msg":"Session key invalid or no longer valid" Thanks for any insight. On Mon Mar 09 15:40:35 2009, clayton.scott@gmail.com wrote: Show quoted text
> This may have to do with it being a desktop app. > I've never built one before, only we apps. > > I'll try to have a poke at this tonight and see if I can help you out. > > Clayton > > On Mon, Mar 9, 2009 at 2:24 PM, JEFFA via RT > <bug-WWW-Facebook-API@rt.cpan.org> wrote:
> > Mon Mar 09 14:24:27 2009: Request 43972 was acted upon. > > Transaction: Ticket created by JEFFA > >       Queue: WWW-Facebook-API > >     Subject: Possible bug -- but could be my misunderstanding > >   Broken in: (no value) > >    Severity: Unimportant > >       Owner: Nobody > >  Requestors: JEFFA@cpan.org > >      Status: new > >  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=43972 > > > > > > > Greetings! > > > > I am trying to use WWW::Facebook::API and i cannot seem to even get
> to
> > first base with it. Here is my sample code: > > > > ============================================ > > use strict; > > use warnings; > > > > use WWW::Facebook::API; > > > > my $api = WWW::Facebook::API->new( > >    desktop => 1, > >    app_id  => 'yes this is my correct app id', > >    api_key => 'yes this is my correct api key', > >    secret  => 'yes this is my correct secret key', > > ); > > > > $api->auth->get_session( $api->auth->create_token ); > > ============================================ > > > > I have verified my various keys and they are correct, however when
> this
> > code is run Facebook returns the following error: > > > > > > ============================================ > > Error during REST auth.getSession call: > > params = > > api_key:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > > auth_token:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > > call_id:1236621974.82341 > > format:JSON > > method:facebook.auth.getSession > > v:1.0 > > response = > > {"error_code":100,"error_msg":"Invalid > >
>
parameter","request_args":[{"key":"api_key","value":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"},{"key":"auth_token","value":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"},{"key":"call_id","value":"1236621974.82341"},{"key":"format","value":"JSON"},{"key":"method","value":"facebook.auth.getSession"},{"key":"v","value":"1.0"},{"key":"sig","value":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}]} Show quoted text
> > at /usr/lib/perl5/site_perl/5.8.8/WWW/Facebook/API.pm line 212 > > ============================================ > > > > I am stumped and perplexed. The only clue that Facebook discloses is > > that there is an "Invalid parameter" ... which could be anything. My > > inclination is to believe that they changed their API and > > WWW::Facebook::API is not up to date, but it seems more likely that
> i am
> > not using the module correctly. Some more examples in the docs would
> be
> > helpful. Like maybe a cookbook. :) > > > > Any help you can offer would be splendid. Thanks in advance. > >
> > >
Jeffa, I think what happening to you is that your session key expired when you logged out of Facebook. Session keys really only last for the session now. You can allow the app to access your account when you're offline by enabling offline access: http://wiki.developers.facebook.com/index.php/New_Design_User_Login_FAQ I have also attached another example app with some included instructions. I have only had time to verify that it compiles not that it and the instructions work. You should be warned that the facebook platform is oddly documented and there are new bugs released with every code release (each and every Tuesday!). If you want to try it out I can help you with any issues that come up and we should have a better example app with good documentation. If you're game, that is. Clayton On Mon Mar 09 16:26:33 2009, JEFFA wrote: Show quoted text
> Thanks for the super speedy reply. :) > > FWIW, i really am not planning on using a desktop app, i simply was > trying to isolate the issue. > > I am trying to get a list of my friends from the API and i really just > don't understand the steps needed to do so. Here is my code: > > ============================================ > my $api = WWW::Facebook::API->new( > desktop => 0, > app_id => 'XXXXXXXXXX', > api_key => 'XXXXXXXXXX', > secret => 'XXXXXXXXXX', > ); > > my $auth_token = param( 'fb_sig_session_key' ); > > $api->auth->get_session( $auth_token ); > ============================================ > > And i get the same error: > > "error_code":100,"error_msg":"Invalid parameter" > > If i do not call get_session() and try to simply call friends->get() > then i receive the error: > > "error_code":102,"error_msg":"Session key invalid or no longer valid" > > Thanks for any insight. > > > > On Mon Mar 09 15:40:35 2009, clayton.scott@gmail.com wrote:
> > This may have to do with it being a desktop app. > > I've never built one before, only we apps. > > > > I'll try to have a poke at this tonight and see if I can help you
> out.
> > > > Clayton > > > > On Mon, Mar 9, 2009 at 2:24 PM, JEFFA via RT > > <bug-WWW-Facebook-API@rt.cpan.org> wrote:
> > > Mon Mar 09 14:24:27 2009: Request 43972 was acted upon. > > > Transaction: Ticket created by JEFFA > > >       Queue: WWW-Facebook-API > > >     Subject: Possible bug -- but could be my misunderstanding > > >   Broken in: (no value) > > >    Severity: Unimportant > > >       Owner: Nobody > > >  Requestors: JEFFA@cpan.org > > >      Status: new > > >  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=43972 > > > > > > > > > > Greetings! > > > > > > I am trying to use WWW::Facebook::API and i cannot seem to even
> get
> > to
> > > first base with it. Here is my sample code: > > > > > > ============================================ > > > use strict; > > > use warnings; > > > > > > use WWW::Facebook::API; > > > > > > my $api = WWW::Facebook::API->new( > > >    desktop => 1, > > >    app_id  => 'yes this is my correct app id', > > >    api_key => 'yes this is my correct api key', > > >    secret  => 'yes this is my correct secret key', > > > ); > > > > > > $api->auth->get_session( $api->auth->create_token ); > > > ============================================ > > > > > > I have verified my various keys and they are correct, however when
> > this
> > > code is run Facebook returns the following error: > > > > > > > > > ============================================ > > > Error during REST auth.getSession call: > > > params = > > > api_key:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > > > auth_token:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > > > call_id:1236621974.82341 > > > format:JSON > > > method:facebook.auth.getSession > > > v:1.0 > > > response = > > > {"error_code":100,"error_msg":"Invalid > > >
> >
>
parameter","request_args":[{"key":"api_key","value":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"},{"key":"auth_token","value":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"},{"key":"call_id","value":"1236621974.82341"},{"key":"format","value":"JSON"},{"key":"method","value":"facebook.auth.getSession"},{"key":"v","value":"1.0"},{"key":"sig","value":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}]} Show quoted text
> > > at /usr/lib/perl5/site_perl/5.8.8/WWW/Facebook/API.pm line 212 > > > ============================================ > > > > > > I am stumped and perplexed. The only clue that Facebook discloses
> is
> > > that there is an "Invalid parameter" ... which could be anything.
> My
> > > inclination is to believe that they changed their API and > > > WWW::Facebook::API is not up to date, but it seems more likely
> that
> > i am
> > > not using the module correctly. Some more examples in the docs
> would
> > be
> > > helpful. Like maybe a cookbook. :) > > > > > > Any help you can offer would be splendid. Thanks in advance. > > >
> > > > > >
> >
#!/usr/local/bin/perl use strict; use warnings; use CGI; use WWW::Facebook::API; my $q = CGI->new(); my $fb = TP::Facebook::API->new( api_key => 'XXXXXXXXXXXXXXXXXXX', secret => 'YYYYYYYYYYYYYYYYYYY', ); # Valid actions for our application to run my %ACTIONS = ( canvas => \&render_canvas, post_add => \&post_add, ); # Require the user to be logged in to interact with our application my $FBML = $fb->require_login($q) unless $fb->users->get_logged_in_user; $FBML .= $fb->require_add($q) || ' '; #requires that the user have added the application to interact with the canvas # Run the subroutine for the selected action if ( defined $ACTIONS{ $q->param('action') } ){ $FBML .= $ACTIONS{ $q->param('action') }->($q,$fb); } else { $FBML .= render_canvas($q); } # return the page print $q->header( -type => 'text/html'); print sprintf '<fb:fbml>%s</fb:fbml>', $FBML; sub render_canvas { my ($query, $fb) = @_; my $friends = $fb->friends->get(); my $fbml = "These are your friends:<br>"; $fbml .= sprintf('<fb:profile-pic uid="%d" linked="true" />', $_) for @$friends; return "I'm on the canvas"; } sub post_add { my ($query, $fb) = @_; my $response = $fb->profile->set_fbml( uid => $fb->logged_in_user, profile => render_profile() ); if ( not $fb->last_call_success ){ warn "FACEBOOK: Unable to push fbml to profile: $response->{error_code} - $response->{error_msg} "; } } sub render_profile { return "Hello, <br> This is the profile of <fb:name uid='profileowner'>" } __END__ 0. Review Basic Application Architecture: http://wiki.developers.facebook.com/index.php/Random_questions#Basic_Application_Architecture 1. Install WWW::Facebok::API on your webserver 2. Install this application on your webserver as <server>/cgi-bin/facebook_test.pl 3. Add the facebook developer application 4. Create a new application 4a Basic Tab: Callback url: <server>/cgi-bin/facebook_test.pl 4b Authentication Tab: Post-Authorize callback url: <server>/cgi-bin/facebook_test.pl?action=post_add 4c Canvas Tab: Canvas url: <pick one that you like and that is available> 4d Fillout whatever else is required 4e Click save changes 5. Point your browser to your canvas url from step 4c 6. Add the application 7. Get familiar with the developer forums and wiki: http://wiki.developers.facebook.com
Thank you so very much, Clayton. I will try this out today and if i can help with documentation in anyway then i would love to help out. I find it a crying shame that Facebook picked PHP over as their "one true ring." The path of least resistance leads to least every time. On Mon Mar 09 23:47:34 2009, CLSCOTT wrote: Show quoted text
> Jeffa, > I think what happening to you is that your session key expired > when you logged out of Facebook. > > Session keys really only last for the session now. > > You can allow the app to access your account when you're offline by > enabling offline access: > http://wiki.developers.facebook.com/index.php/New_Design_User_Login_FAQ > > I have also attached another example app with some included > instructions. I have only had time to verify that it compiles not that > it and the instructions work. > > You should be warned that the facebook platform is oddly documented > and > there are new bugs released with every code release (each and every > Tuesday!). > > If you want to try it out I can help you with any issues that come up > and we should have a better example app with good documentation. > > If you're game, that is. > > Clayton > > On Mon Mar 09 16:26:33 2009, JEFFA wrote:
> > Thanks for the super speedy reply. :) > > > > FWIW, i really am not planning on using a desktop app, i simply was > > trying to isolate the issue. > > > > I am trying to get a list of my friends from the API and i really
> just
> > don't understand the steps needed to do so. Here is my code: > > > > ============================================ > > my $api = WWW::Facebook::API->new( > > desktop => 0, > > app_id => 'XXXXXXXXXX', > > api_key => 'XXXXXXXXXX', > > secret => 'XXXXXXXXXX', > > ); > > > > my $auth_token = param( 'fb_sig_session_key' ); > > > > $api->auth->get_session( $auth_token ); > > ============================================ > > > > And i get the same error: > > > > "error_code":100,"error_msg":"Invalid parameter" > > > > If i do not call get_session() and try to simply call friends->get() > > then i receive the error: > > > > "error_code":102,"error_msg":"Session key invalid or no longer
> valid"
> > > > Thanks for any insight. > > > > > > > > On Mon Mar 09 15:40:35 2009, clayton.scott@gmail.com wrote:
> > > This may have to do with it being a desktop app. > > > I've never built one before, only we apps. > > > > > > I'll try to have a poke at this tonight and see if I can help you
> > out.
> > > > > > Clayton > > > > > > On Mon, Mar 9, 2009 at 2:24 PM, JEFFA via RT > > > <bug-WWW-Facebook-API@rt.cpan.org> wrote:
> > > > Mon Mar 09 14:24:27 2009: Request 43972 was acted upon. > > > > Transaction: Ticket created by JEFFA > > > >       Queue: WWW-Facebook-API > > > >     Subject: Possible bug -- but could be my misunderstanding > > > >   Broken in: (no value) > > > >    Severity: Unimportant > > > >       Owner: Nobody > > > >  Requestors: JEFFA@cpan.org > > > >      Status: new > > > >  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=43972 > > > > > > > > > > > > > Greetings! > > > > > > > > I am trying to use WWW::Facebook::API and i cannot seem to even
> > get
> > > to
> > > > first base with it. Here is my sample code: > > > > > > > > ============================================ > > > > use strict; > > > > use warnings; > > > > > > > > use WWW::Facebook::API; > > > > > > > > my $api = WWW::Facebook::API->new( > > > >    desktop => 1, > > > >    app_id  => 'yes this is my correct app id', > > > >    api_key => 'yes this is my correct api key', > > > >    secret  => 'yes this is my correct secret key', > > > > ); > > > > > > > > $api->auth->get_session( $api->auth->create_token ); > > > > ============================================ > > > > > > > > I have verified my various keys and they are correct, however
> when
> > > this
> > > > code is run Facebook returns the following error: > > > > > > > > > > > > ============================================ > > > > Error during REST auth.getSession call: > > > > params = > > > > api_key:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > > > > auth_token:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > > > > call_id:1236621974.82341 > > > > format:JSON > > > > method:facebook.auth.getSession > > > > v:1.0 > > > > response = > > > > {"error_code":100,"error_msg":"Invalid > > > >
> > >
> >
>
parameter","request_args":[{"key":"api_key","value":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"},{"key":"auth_token","value":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"},{"key":"call_id","value":"1236621974.82341"},{"key":"format","value":"JSON"},{"key":"method","value":"facebook.auth.getSession"},{"key":"v","value":"1.0"},{"key":"sig","value":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}]} Show quoted text
> > > > at /usr/lib/perl5/site_perl/5.8.8/WWW/Facebook/API.pm line 212 > > > > ============================================ > > > > > > > > I am stumped and perplexed. The only clue that Facebook
> discloses
> > is
> > > > that there is an "Invalid parameter" ... which could be
> anything.
> > My
> > > > inclination is to believe that they changed their API and > > > > WWW::Facebook::API is not up to date, but it seems more likely
> > that
> > > i am
> > > > not using the module correctly. Some more examples in the docs
> > would
> > > be
> > > > helpful. Like maybe a cookbook. :) > > > > > > > > Any help you can offer would be splendid. Thanks in advance. > > > >
> > > > > > > > >
> > > >
> >
OK, i tried out your app and apart from having to replace TP::Facebook::API with WWW::Facebook::API -- i only replaced the secret and api keys. I am still getting errors, this time Facebook is saying that getLoggedInUser() requires a session key: "error_code":453,"error_msg":"A session key is required for calling this method" I am not sure what you mean by my session key expiring. My user is still logged into Facebook when i try to access this App from Facebook. Was i supposed to add more code to this example to get it to work? It seems that every API call requires a session key ... but to get the session key i need to make an API call ... that requires a session key. :/ Thanks for the help so far, by the way. On Mon Mar 09 23:47:34 2009, CLSCOTT wrote: Show quoted text
> Jeffa, > I think what happening to you is that your session key expired > when you logged out of Facebook. > > Session keys really only last for the session now. > > You can allow the app to access your account when you're offline by > enabling offline access: > http://wiki.developers.facebook.com/index.php/New_Design_User_Login_FAQ > > I have also attached another example app with some included > instructions. I have only had time to verify that it compiles not that > it and the instructions work. > > You should be warned that the facebook platform is oddly documented > and > there are new bugs released with every code release (each and every > Tuesday!). > > If you want to try it out I can help you with any issues that come up > and we should have a better example app with good documentation. > > If you're game, that is. > > Clayton > > On Mon Mar 09 16:26:33 2009, JEFFA wrote:
> > Thanks for the super speedy reply. :) > > > > FWIW, i really am not planning on using a desktop app, i simply was > > trying to isolate the issue. > > > > I am trying to get a list of my friends from the API and i really
> just
> > don't understand the steps needed to do so. Here is my code: > > > > ============================================ > > my $api = WWW::Facebook::API->new( > > desktop => 0, > > app_id => 'XXXXXXXXXX', > > api_key => 'XXXXXXXXXX', > > secret => 'XXXXXXXXXX', > > ); > > > > my $auth_token = param( 'fb_sig_session_key' ); > > > > $api->auth->get_session( $auth_token ); > > ============================================ > > > > And i get the same error: > > > > "error_code":100,"error_msg":"Invalid parameter" > > > > If i do not call get_session() and try to simply call friends->get() > > then i receive the error: > > > > "error_code":102,"error_msg":"Session key invalid or no longer
> valid"
> > > > Thanks for any insight. > > > > > > > > On Mon Mar 09 15:40:35 2009, clayton.scott@gmail.com wrote:
> > > This may have to do with it being a desktop app. > > > I've never built one before, only we apps. > > > > > > I'll try to have a poke at this tonight and see if I can help you
> > out.
> > > > > > Clayton > > > > > > On Mon, Mar 9, 2009 at 2:24 PM, JEFFA via RT > > > <bug-WWW-Facebook-API@rt.cpan.org> wrote:
> > > > Mon Mar 09 14:24:27 2009: Request 43972 was acted upon. > > > > Transaction: Ticket created by JEFFA > > > >       Queue: WWW-Facebook-API > > > >     Subject: Possible bug -- but could be my misunderstanding > > > >   Broken in: (no value) > > > >    Severity: Unimportant > > > >       Owner: Nobody > > > >  Requestors: JEFFA@cpan.org > > > >      Status: new > > > >  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=43972 > > > > > > > > > > > > > Greetings! > > > > > > > > I am trying to use WWW::Facebook::API and i cannot seem to even
> > get
> > > to
> > > > first base with it. Here is my sample code: > > > > > > > > ============================================ > > > > use strict; > > > > use warnings; > > > > > > > > use WWW::Facebook::API; > > > > > > > > my $api = WWW::Facebook::API->new( > > > >    desktop => 1, > > > >    app_id  => 'yes this is my correct app id', > > > >    api_key => 'yes this is my correct api key', > > > >    secret  => 'yes this is my correct secret key', > > > > ); > > > > > > > > $api->auth->get_session( $api->auth->create_token ); > > > > ============================================ > > > > > > > > I have verified my various keys and they are correct, however
> when
> > > this
> > > > code is run Facebook returns the following error: > > > > > > > > > > > > ============================================ > > > > Error during REST auth.getSession call: > > > > params = > > > > api_key:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > > > > auth_token:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > > > > call_id:1236621974.82341 > > > > format:JSON > > > > method:facebook.auth.getSession > > > > v:1.0 > > > > response = > > > > {"error_code":100,"error_msg":"Invalid > > > >
> > >
> >
>
parameter","request_args":[{"key":"api_key","value":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"},{"key":"auth_token","value":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"},{"key":"call_id","value":"1236621974.82341"},{"key":"format","value":"JSON"},{"key":"method","value":"facebook.auth.getSession"},{"key":"v","value":"1.0"},{"key":"sig","value":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}]} Show quoted text
> > > > at /usr/lib/perl5/site_perl/5.8.8/WWW/Facebook/API.pm line 212 > > > > ============================================ > > > > > > > > I am stumped and perplexed. The only clue that Facebook
> discloses
> > is
> > > > that there is an "Invalid parameter" ... which could be
> anything.
> > My
> > > > inclination is to believe that they changed their API and > > > > WWW::Facebook::API is not up to date, but it seems more likely
> > that
> > > i am
> > > > not using the module correctly. Some more examples in the docs
> > would
> > > be
> > > > helpful. Like maybe a cookbook. :) > > > > > > > > Any help you can offer would be splendid. Thanks in advance. > > > >
> > > > > > > > >
> > > >
> >
Sorry about the trouble. This one should work. I ended up taking over maintenance for this module when I needed it for work and the author became to busy. I've never really delved into it in depth. Ive been poking around and reading more of the documents and seeing how out of date some of it is. Here's another copy of the file that gets and sets the session. This should be rolled back into the library some time soon. Again it's untested, it appears that Facebook is unreacha=ble for me tonight. I will be away over the weekend. This should get you far enough to be able to see communiction back and forth. If you have any feedback or patches I'd be happy to roll them in. Clayton On Tue Mar 10 17:35:29 2009, JEFFA wrote: Show quoted text
> OK, i tried out your app and apart from having to replace > TP::Facebook::API with WWW::Facebook::API -- i only replaced the > secret > and api keys. > > I am still getting errors, this time Facebook is saying that > getLoggedInUser() requires a session key: > > "error_code":453,"error_msg":"A session key is required for calling > this > method" > > I am not sure what you mean by my session key expiring. My user is > still > logged into Facebook when i try to access this App from Facebook. Was > i > supposed to add more code to this example to get it to work? It seems > that every API call requires a session key ... but to get the session > key i need to make an API call ... that requires a session key. :/ > > Thanks for the help so far, by the way. > > > > On Mon Mar 09 23:47:34 2009, CLSCOTT wrote:
> > Jeffa, > > I think what happening to you is that your session key expired > > when you logged out of Facebook. > > > > Session keys really only last for the session now. > > > > You can allow the app to access your account when you're offline by > > enabling offline access: > >
> http://wiki.developers.facebook.com/index.php/New_Design_User_Login_FAQ
> > > > I have also attached another example app with some included > > instructions. I have only had time to verify that it compiles not
> that
> > it and the instructions work. > > > > You should be warned that the facebook platform is oddly documented > > and > > there are new bugs released with every code release (each and every > > Tuesday!). > > > > If you want to try it out I can help you with any issues that come
> up
> > and we should have a better example app with good documentation. > > > > If you're game, that is. > > > > Clayton > > > > On Mon Mar 09 16:26:33 2009, JEFFA wrote:
> > > Thanks for the super speedy reply. :) > > > > > > FWIW, i really am not planning on using a desktop app, i simply
> was
> > > trying to isolate the issue. > > > > > > I am trying to get a list of my friends from the API and i really
> > just
> > > don't understand the steps needed to do so. Here is my code: > > > > > > ============================================ > > > my $api = WWW::Facebook::API->new( > > > desktop => 0, > > > app_id => 'XXXXXXXXXX', > > > api_key => 'XXXXXXXXXX', > > > secret => 'XXXXXXXXXX', > > > ); > > > > > > my $auth_token = param( 'fb_sig_session_key' ); > > > > > > $api->auth->get_session( $auth_token ); > > > ============================================ > > > > > > And i get the same error: > > > > > > "error_code":100,"error_msg":"Invalid parameter" > > > > > > If i do not call get_session() and try to simply call friends-
> >get()
> > > then i receive the error: > > > > > > "error_code":102,"error_msg":"Session key invalid or no longer
> > valid"
> > > > > > Thanks for any insight. > > > > > > > > > > > > On Mon Mar 09 15:40:35 2009, clayton.scott@gmail.com wrote:
> > > > This may have to do with it being a desktop app. > > > > I've never built one before, only we apps. > > > > > > > > I'll try to have a poke at this tonight and see if I can help
> you
> > > out.
> > > > > > > > Clayton > > > > > > > > On Mon, Mar 9, 2009 at 2:24 PM, JEFFA via RT > > > > <bug-WWW-Facebook-API@rt.cpan.org> wrote:
> > > > > Mon Mar 09 14:24:27 2009: Request 43972 was acted upon. > > > > > Transaction: Ticket created by JEFFA > > > > >       Queue: WWW-Facebook-API > > > > >     Subject: Possible bug -- but could be my misunderstanding > > > > >   Broken in: (no value) > > > > >    Severity: Unimportant > > > > >       Owner: Nobody > > > > >  Requestors: JEFFA@cpan.org > > > > >      Status: new > > > > >  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=43972
> >
> > > > > > > > > > > > > > > Greetings! > > > > > > > > > > I am trying to use WWW::Facebook::API and i cannot seem to
> even
> > > get
> > > > to
> > > > > first base with it. Here is my sample code: > > > > > > > > > > ============================================ > > > > > use strict; > > > > > use warnings; > > > > > > > > > > use WWW::Facebook::API; > > > > > > > > > > my $api = WWW::Facebook::API->new( > > > > >    desktop => 1, > > > > >    app_id  => 'yes this is my correct app id', > > > > >    api_key => 'yes this is my correct api key', > > > > >    secret  => 'yes this is my correct secret key', > > > > > ); > > > > > > > > > > $api->auth->get_session( $api->auth->create_token ); > > > > > ============================================ > > > > > > > > > > I have verified my various keys and they are correct, however
> > when
> > > > this
> > > > > code is run Facebook returns the following error: > > > > > > > > > > > > > > > ============================================ > > > > > Error during REST auth.getSession call: > > > > > params = > > > > > api_key:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > > > > > auth_token:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > > > > > call_id:1236621974.82341 > > > > > format:JSON > > > > > method:facebook.auth.getSession > > > > > v:1.0 > > > > > response = > > > > > {"error_code":100,"error_msg":"Invalid > > > > >
> > > >
> > >
> >
>
parameter","request_args":[{"key":"api_key","value":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"},{"key":"auth_token","value":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"},{"key":"call_id","value":"1236621974.82341"},{"key":"format","value":"JSON"},{"key":"method","value":"facebook.auth.getSession"},{"key":"v","value":"1.0"},{"key":"sig","value":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}]} Show quoted text
> > > > > at /usr/lib/perl5/site_perl/5.8.8/WWW/Facebook/API.pm line 212 > > > > > ============================================ > > > > > > > > > > I am stumped and perplexed. The only clue that Facebook
> > discloses
> > > is
> > > > > that there is an "Invalid parameter" ... which could be
> > anything.
> > > My
> > > > > inclination is to believe that they changed their API and > > > > > WWW::Facebook::API is not up to date, but it seems more likely
> > > that
> > > > i am
> > > > > not using the module correctly. Some more examples in the docs
> > > would
> > > > be
> > > > > helpful. Like maybe a cookbook. :) > > > > > > > > > > Any help you can offer would be splendid. Thanks in advance. > > > > >
> > > > > > > > > > > >
> > > > > >
> > > >
> >
#!/usr/local/bin/perl use strict; use warnings; use CGI; use WWW::Facebook::API; my $q = CGI->new(); my ($id, $session) = facebook_credentials( $q ); my $fb = WWW::Facebook::API->new( api_key => 'XXXXXXXXXXXXXXXXXXX', secret => 'YYYYYYYYYYYYYYYYYYY', session_uid => $id, session_key => $session, ); # Valid actions for our application to run my %ACTIONS = ( canvas => \&render_canvas, post_add => \&post_add, ); # Require the user to be logged in to interact with our application my $FBML = $fb->require_login($q) unless $fb->users->get_logged_in_user; $FBML .= $fb->require_add($q) || ' '; #requires that the user have added the application to interact with the canvas # Run the subroutine for the selected action if ( defined $ACTIONS{ $q->param('action') } ){ $FBML .= $ACTIONS{ $q->param('action') }->($q,$fb); } else { $FBML .= render_canvas($q); } # return the page print $q->header( -type => 'text/html'); print sprintf '<fb:fbml>%s</fb:fbml>', $FBML; sub render_canvas { my ($query, $fb) = @_; my $friends = $fb->friends->get(); my $fbml = "These are your friends:<br>"; $fbml .= sprintf('<fb:profile-pic uid="%d" linked="true" />', $_) for @$friends; return "I'm on the canvas"; } sub post_add { my ($query, $fb) = @_; my $response = $fb->profile->set_fbml( uid => $fb->logged_in_user, profile => render_profile() ); if ( not $fb->last_call_success ){ warn "FACEBOOK: Unable to push fbml to profile: $response->{error_code} - $response->{error_msg} "; } } sub render_profile { return "Hello, <br> This is the profile of <fb:name uid='profileowner'>" } sub facebook_credentials { my $q = shift; my $fb_uid = $q->param('fb_sig_user') || $q->param('fb_sig_profile_user') || $q->param('fb_sig_canvas_user'); my $fb_session = $q->param('fb_sig_session_key') || $q->param('fb_profile_session_key') || $q->param('fb_canvas_session_key'); return $fb_uid, $fb_session; } __END__ 0. Review Basic Application Architecture: http://wiki.developers.facebook.com/index.php/Random_questions#Basic_Application_Architecture 1. Install WWW::Facebok::API on your webserver 2. Install this application on your webserver as <server>/cgi-bin/facebook_test.pl 3. Add the facebook developer application 4. Create a new application 4a Basic Tab: Callback url: <server>/cgi-bin/facebook_test.pl 4b Authentication Tab: Post-Authorize callback url: <server>/cgi-bin/facebook_test.pl?action=post_add 4c Canvas Tab: Canvas url: <pick one that you like and that is available> 4d Fillout whatever else is required 4e Click save changes 5. Point your browser to your canvas url from step 4c 6. Add the application 7. Get familiar with the developer forums and wiki: http://wiki.developers.facebook.com
Thanks for this Clayton, i was able to get this one to work beautifully. I had to make a couple of changes: # call to render_canvas was not passing $fb as 2nd arg $FBML .= render_canvas( $q, $fb ); # return from render_canvas was not returning $fbml return $fbml . "<p>I'm on the canvas</p>"; I attached a patch as well. Other than that it worked like a charm. I should be able to figure out all the handshaking now. I should be working the Facebook API extensively, so anything i can add to the project i will gladly send your way: patches, sample code etc. Thanks again! -- jeffa On Thu Mar 12 22:06:42 2009, CLSCOTT wrote: Show quoted text
> Sorry about the trouble. This one should work. > > I ended up taking over maintenance for this module when > I needed it for work and the author became to busy. > I've never really delved into it in depth. Ive been poking around and > reading more of the documents and seeing how out of date some of it > is. > > Here's another copy of the file that gets and sets the session. > > This should be rolled back into the library some time soon. > > Again it's untested, it appears that Facebook is unreacha=ble for me > tonight. > > I will be away over the weekend. This should get you far enough to be > able to see communiction back and forth. > > If you have any feedback or patches I'd be happy to roll them in. > > Clayton > > On Tue Mar 10 17:35:29 2009, JEFFA wrote:
> > OK, i tried out your app and apart from having to replace > > TP::Facebook::API with WWW::Facebook::API -- i only replaced the > > secret > > and api keys. > > > > I am still getting errors, this time Facebook is saying that > > getLoggedInUser() requires a session key: > > > > "error_code":453,"error_msg":"A session key is required for calling > > this > > method" > > > > I am not sure what you mean by my session key expiring. My user is > > still > > logged into Facebook when i try to access this App from Facebook.
> Was
> > i > > supposed to add more code to this example to get it to work? It
> seems
> > that every API call requires a session key ... but to get the
> session
> > key i need to make an API call ... that requires a session key. :/ > > > > Thanks for the help so far, by the way. > > > > > > > > On Mon Mar 09 23:47:34 2009, CLSCOTT wrote:
> > > Jeffa, > > > I think what happening to you is that your session key expired > > > when you logged out of Facebook. > > > > > > Session keys really only last for the session now. > > > > > > You can allow the app to access your account when you're offline
> by
> > > enabling offline access: > > >
> >
> http://wiki.developers.facebook.com/index.php/New_Design_User_Login_FAQ
> > > > > > I have also attached another example app with some included > > > instructions. I have only had time to verify that it compiles not
> > that
> > > it and the instructions work. > > > > > > You should be warned that the facebook platform is oddly
> documented
> > > and > > > there are new bugs released with every code release (each and
> every
> > > Tuesday!). > > > > > > If you want to try it out I can help you with any issues that come
> > up
> > > and we should have a better example app with good documentation. > > > > > > If you're game, that is. > > > > > > Clayton > > > > > > On Mon Mar 09 16:26:33 2009, JEFFA wrote:
> > > > Thanks for the super speedy reply. :) > > > > > > > > FWIW, i really am not planning on using a desktop app, i simply
> > was
> > > > trying to isolate the issue. > > > > > > > > I am trying to get a list of my friends from the API and i
> really
> > > just
> > > > don't understand the steps needed to do so. Here is my code: > > > > > > > > ============================================ > > > > my $api = WWW::Facebook::API->new( > > > > desktop => 0, > > > > app_id => 'XXXXXXXXXX', > > > > api_key => 'XXXXXXXXXX', > > > > secret => 'XXXXXXXXXX', > > > > ); > > > > > > > > my $auth_token = param( 'fb_sig_session_key' ); > > > > > > > > $api->auth->get_session( $auth_token ); > > > > ============================================ > > > > > > > > And i get the same error: > > > > > > > > "error_code":100,"error_msg":"Invalid parameter" > > > > > > > > If i do not call get_session() and try to simply call friends-
> > >get()
> > > > then i receive the error: > > > > > > > > "error_code":102,"error_msg":"Session key invalid or no longer
> > > valid"
> > > > > > > > Thanks for any insight. > > > > > > > > > > > > > > > > On Mon Mar 09 15:40:35 2009, clayton.scott@gmail.com wrote:
> > > > > This may have to do with it being a desktop app. > > > > > I've never built one before, only we apps. > > > > > > > > > > I'll try to have a poke at this tonight and see if I can help
> > you
> > > > out.
> > > > > > > > > > Clayton > > > > > > > > > > On Mon, Mar 9, 2009 at 2:24 PM, JEFFA via RT > > > > > <bug-WWW-Facebook-API@rt.cpan.org> wrote:
> > > > > > Mon Mar 09 14:24:27 2009: Request 43972 was acted upon. > > > > > > Transaction: Ticket created by JEFFA > > > > > >       Queue: WWW-Facebook-API > > > > > >     Subject: Possible bug -- but could be my
> misunderstanding
> > > > > >   Broken in: (no value) > > > > > >    Severity: Unimportant > > > > > >       Owner: Nobody > > > > > >  Requestors: JEFFA@cpan.org > > > > > >      Status: new > > > > > >  Ticket <URL:
> https://rt.cpan.org/Ticket/Display.html?id=43972
> > >
> > > > > > > > > > > > > > > > > > Greetings! > > > > > > > > > > > > I am trying to use WWW::Facebook::API and i cannot seem to
> > even
> > > > get
> > > > > to
> > > > > > first base with it. Here is my sample code: > > > > > > > > > > > > ============================================ > > > > > > use strict; > > > > > > use warnings; > > > > > > > > > > > > use WWW::Facebook::API; > > > > > > > > > > > > my $api = WWW::Facebook::API->new( > > > > > >    desktop => 1, > > > > > >    app_id  => 'yes this is my correct app id', > > > > > >    api_key => 'yes this is my correct api key', > > > > > >    secret  => 'yes this is my correct secret key', > > > > > > ); > > > > > > > > > > > > $api->auth->get_session( $api->auth->create_token ); > > > > > > ============================================ > > > > > > > > > > > > I have verified my various keys and they are correct,
> however
> > > when
> > > > > this
> > > > > > code is run Facebook returns the following error: > > > > > > > > > > > > > > > > > > ============================================ > > > > > > Error during REST auth.getSession call: > > > > > > params = > > > > > > api_key:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > > > > > > auth_token:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > > > > > > call_id:1236621974.82341 > > > > > > format:JSON > > > > > > method:facebook.auth.getSession > > > > > > v:1.0 > > > > > > response = > > > > > > {"error_code":100,"error_msg":"Invalid > > > > > >
> > > > >
> > > >
> > >
> >
>
parameter","request_args":[{"key":"api_key","value":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"},{"key":"auth_token","value":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"},{"key":"call_id","value":"1236621974.82341"},{"key":"format","value":"JSON"},{"key":"method","value":"facebook.auth.getSession"},{"key":"v","value":"1.0"},{"key":"sig","value":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}]} Show quoted text
> > > > > > at /usr/lib/perl5/site_perl/5.8.8/WWW/Facebook/API.pm line
> 212
> > > > > > ============================================ > > > > > > > > > > > > I am stumped and perplexed. The only clue that Facebook
> > > discloses
> > > > is
> > > > > > that there is an "Invalid parameter" ... which could be
> > > anything.
> > > > My
> > > > > > inclination is to believe that they changed their API and > > > > > > WWW::Facebook::API is not up to date, but it seems more
> likely
> > > > that
> > > > > i am
> > > > > > not using the module correctly. Some more examples in the
> docs
> > > > would
> > > > > be
> > > > > > helpful. Like maybe a cookbook. :) > > > > > > > > > > > > Any help you can offer would be splendid. Thanks in advance. > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > >
> > > > > >
> > > >
> >
--- facebook_api_example.pl 2009-03-13 08:58:27.000000000 -0400 +++ facebook_api_example_new.pl 2009-03-13 10:38:15.000000000 -0400 @@ -31,7 +31,7 @@ if ( defined $ACTIONS{ $q->param('action') } ){ $FBML .= $ACTIONS{ $q->param('action') }->($q,$fb); } else { - $FBML .= render_canvas($q); + $FBML .= render_canvas($q,$fb); } # return the page @@ -46,7 +46,7 @@ my $fbml = "These are your friends:<br>"; $fbml .= sprintf('<fb:profile-pic uid="%d" linked="true" />', $_) for @$friends; - return "I'm on the canvas"; + return $fbml . "I'm on the canvas"; } sub post_add {