Perl facebook graph giving Could not fetch access token: Bad Request at /usr/local/share/perl/5.10.1/Facebook/Graph/AccessToken/Response.pm -


i trying access token getting error as

bad request @ /usr/local/share/perl/5.10.1/facebook/graph/accesstoken/response.pm line 26

following code

use facebook::graph                                     ;   $fb = facebook::graph->new(      app_id          => $facebook_app_id,      secret          => $facebook_app_secret,      postback        => $postback_url,     );   $uri = $fb     ->authorize     ->extend_permissions(qw(offline_access publish_stream))     ->uri_as_string; 

it successful redirecting postback url , getting code paramater

my code in postback url / page

use facebook::graph                                     ;  $fb = facebook::graph->new(      app_id          => $facebook_app_id,      secret          => $facebook_app_secret,      postback        => $postback_url,      ); 

when doing $fb->request_access_token( $code ) ;

i getting error not fetch access token: bad request @ /usr/local/share/perl/5.10.1/facebook/graph/accesstoken/response.pm line 26

please in advance.

i used first snippet generate code using own application.

after manually getting code:

#!/usr/bin/perl use strict; use warnings; $facebook_app_id =     'myapp'; $facebook_app_secret = 'secret' $postback_url =        'http://localhost:8321/'; $code =                '...';  use facebook::graph; use data::dumper;  $fb = facebook::graph->new(    app_id          => $facebook_app_id,    secret          => $facebook_app_secret,    postback        => $postback_url, ); print dumper $fb->request_access_token($code); 

this dumped out expected json repsonse 'token' => '...tokenval...'

i able recreate error posted modifying postback value other used when creating code. includes adding or removing trailing slash. make sure postback url matches!!

could not fetch access token: bad request @ /users/andrew/perl5/lib/perl5/facebook/graph/accesstoken/response.pm line 26.

similarly, if hold onto $code long expire. must create new one. can save/cache access_token returned request_access_token. don't last long, can request longer lived 1 recent facebook api changes.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -