doubledecker has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks
I've written the following code to login to facebook from my website and seems to be broken
The following is fb.pl prompts to enter FB username and password. However it is failing to postback with data from the facebook pages
#!/usr/bin/perl use Facebook::Graph; use CGI; my $q = new CGI; my $APP_ID = "MY_SECRET_APP_ID"; my $SECRET = "MY_SECRET_CODE"; my $POSTBACK_URL = "http://my.own.domain.com/postback.pl"; my $fb = Facebook::Graph->new( app_id => $APP_ID, secret => $SECRET, postback => $POSTBACK_URL, ); my $uri = $fb ->authorize ->extend_permissions(qw(offline_access publish_stream email user_l +ocation)) ->uri_as_string; print $q->redirect($uri);
Postback script
#!/usr/bin/perl use strict; use HTTP::Request::Common; use CGI; use Facebook::Graph; my $APP_ID = "MY_SECRET_APP_ID"; my $SECRET = "MY_SECRET_CODE"; # # Am I doing anything wrong here by setting postback script # pointing to a different domain # my $POSTBACK_URL = "http://some.another.domain.com/postback.pl"; my $fb = Facebook::Graph->new( app_id => $APP_ID, secret => $SECRET, postback => $POSTBACK_URL, ); my $q = new CGI; my $params = $q->Vars; my $code = $params->{'code'}; $fb->request_access_token($code); my $token = $fb->access_token; $fb->request_extended_access_token($token); my $user = $fb->fetch('me'); #register data on amateur; my $login = $user->{'name'}; $login =~ s/\s//g; my %register = ( login => $login, firstname => $user->{'first_name'}, lastname => $user->{'last_name'}, email => $user->{'email'}, action => 'register' ); print $q->redirect("http://my.own.domain.com/cgi/fb.cgi?login=dummyuse +r&msg=201");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Postback URL for facebook
by Corion (Patriarch) on Dec 30, 2014 at 18:25 UTC | |
by doubledecker (Scribe) on Dec 30, 2014 at 19:06 UTC | |
by Corion (Patriarch) on Dec 30, 2014 at 19:59 UTC | |
by doubledecker (Scribe) on Jan 03, 2015 at 12:18 UTC | |
by Corion (Patriarch) on Jan 03, 2015 at 12:48 UTC | |
|
Re: Postback URL for facebook
by oakbox (Chaplain) on Feb 09, 2016 at 13:28 UTC |