Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9229935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:41:49+00:00 2026-06-18T05:41:49+00:00

I want to get FB-user data via the Graph API (with Perl). I have

  • 0

I want to get FB-user data via the Graph API (with Perl).
I have an facebook-application, configured as “Website with FB Login”.
I’m using Net::Facebook::Oauth2

the app is configured with a callbackurl like this: "http://localhost/myfile.pl"

When I open localhost/myfile.pl it lets me login to facebook and also give the application access to my data. But when it comes to the point where it should fall back and getting the access-token (at least I think thats what it should do next) it ends in an endless loop.

http://localhost/myfile.pl contains the following:

#!"C:\strawberry\perl\bin\perl.exe"
use CGI::Carp qw(fatalsToBrowser);  # this makes perl showing (syntax) errors in browser

use CGI;
    my $cgi = CGI->new;

    use Net::Facebook::Oauth2;

    my $fb = Net::Facebook::Oauth2->new(
        application_id => 'xxxMY_APP_IDXXX', 
        application_secret => 'xxxMY_SECRETxxx',
        callback => 'http://localhost/myFile.pl'
    );

    ###get authorization URL for your application
    my $url = $fb->get_authorization_url(
        scope => ['offline_access','publish_stream'],
        display => 'page'
    );

    ####now redirect to this url
    print $cgi->redirect($url);

    ##once user authorizes your application facebook will send him/her back to your application
    ##to the callback link provided above

    ###in your callback block capture verifier code and get access_token

    my $fb = Net::Facebook::Oauth2->new(
        application_id => 'xxxMY_APP_IDxxx',
        application_secret => 'xxxMY_SECRETxxx',
        callback => 'http://localhost/myFile.pl'
    );

    my $access_token = $fb->get_access_token(code => $cgi->param('code'));
    ###save this token in database or session

    ##later on your application you can use this verifier code to comunicate
    ##with facebook on behalf of this user

    my $fb = Net::Facebook::Oauth2->new(
        access_token => $access_token
    );

    my $info = $fb->get(
        'https://graph.facebook.com/me' ##Facebook API URL
    );

    print $info->as_json;

Am I doing something wrong in the Perl script? Or is it because of the localhost for my callback?

Thanks in advance,
Christoph Twrdy

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:41:50+00:00Added an answer on June 18, 2026 at 5:41 am

    You should use a parameter to stop infinite loops happen. Basicly, the app authtenticate to FB then call the same script again, it sees that it is authtenticated and loops forever.

    if ( ! defined $cgi->param('code') ){
      my $access_token = $fb->get_access_token(code => $cgi->param('code'));
      my $fb = Net::Facebook::Oauth2->new(
        application_id => 'xxxMY_APP_IDxxx',
        application_secret => 'xxxMY_SECRETxxx',
        callback => "http://localhost/myFile.pl";
      );
      ###get authorization URL for your application
      my $url = $fb->get_authorization_url(
        scope => ['offline_access','publish_stream'],
        display => 'page'
      );
    
      ####now redirect to this url
      print $cgi->redirect($url);
    
    } else {
      ##later on your application you can use this verifier code to comunicate
      ##with facebook on behalf of this user
      my $access_token = $fb->get_access_token(code => $cgi->param('code'));
      my $fb = Net::Facebook::Oauth2->new(
        access_token => $access_token
      );
    
      my $info = $fb->get(
        'https://graph.facebook.com/me' ##Facebook API URL
      );
    
      print $info->as_json;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to get the user who login now .. how to do this
I want to get the user ID of a given process ID using C
I want to get the following information of a user that is captured using
i want to get the full address of user programatically using c# how can
I want to get data from a DMA enabled, PCIe hardware device into user-space
i want to store and retrieve data via the url hash. the user is
I am using spring mvc 3.0 to build an web application. User can get
I have an extJs Grid with filters etc. I get my data via ajax
I have 2 tables, table_a and table_b . I want to get user_id from
I want to get the user mail address, as shown in this thread :

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.