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

    What does the Facebook documentation say?

    Does it work when you use an URL that is not at some.antoher.domain.com but on your own domain?

      My domain has complete access to install Perl modules which worked out for me. However, on the other domain, I am very much restricted. For this reason I am pointing the POSTBACK script into my domain.

        So, does it work or does it not work?

        Maybe Facebook has a developer sandbox where you can try out whether the parameters you give to Facebook are correct?

Re: Postback URL for facebook
by oakbox (Chaplain) on Feb 09, 2016 at 13:28 UTC