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

  • Home
  • SEARCH
  • 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 9223299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:02:54+00:00 2026-06-18T04:02:54+00:00

I’ve been following the steps outlined here to create a Facebook App Login: http://developers.facebook.com/docs/howtos/login/server-side-login/

  • 0

I’ve been following the steps outlined here to create a Facebook App Login:
http://developers.facebook.com/docs/howtos/login/server-side-login/

And am on Step 3. I’m setting this up on localhost for development and then I’ll publish to Azure Websites with a different App ID. I’d like to have this working on localhost first though. (I haven’t tried this with a non-localhost domain yet.)

On my Facebook App configuration page I’ve set a couple relevant fields:
Site URL: http:// localhost : 8052/ (Spaces added to allow submision to Stack Overflow)
App Domains: localhost

main.php redirects to a login page if there is no Facebook code set. This works fine.

<head>
<?php
   if(!isset($_SESSION['code'])) {
      echo ('<meta http-equiv="REFRESH" content="0;url=/login.php" />');
   }
?>
</head>

login.php redirects to Facebook’s login page using code copied from their example.

<?php

   include '/lib/url.php';

   $app_id = "XXXXX";
   $app_secret = "XXXXX";
   $my_url = CreateUrlForPage('welcome.php');

   session_start();

   $code = '';
   if(!isset($_REQUEST["code"])) {
     $_SESSION['state'] = md5(uniqid(rand(), TRUE)); // CSRF protection
     $dialog_url = "https://www.facebook.com/dialog/oauth?client_id=" 
       . $app_id . "&redirect_uri=" . urlencode($my_url) . "&state="
       . $_SESSION['state'];

     echo $my_url.'<br/>';
     echo $dialog_url.'<br/>';
     echo("<script> top.location.href='" . $dialog_url . "'</script>");
   }
?>  

Clearly I’ve obfuscated my App ID above.

The URL generated by my “CreateUrlForPage” function looks fine as does the facebook login URL:

http://localhost:8052/welcome.php
https://www.facebook.com/dialog/oauth?client_id=XXXX&redirect_uri=http%3A%2F%2Flocalhost%3A8052%2Fwelcome.php&state=XXXX

(Again, some obfuscation here. The real values looked okay. The first being an integer the second being a long hex string.)

When I navigate to http:// localhost : 8052/login.php, The page redirects to Facebook and gives a completely useless error: “An error occurred. Please try again later.”

I looked at a couple other posts on Stack Overflow, but they didn’t solve my problem.

The error I’m getting looks just like the one described here:
Facebook application login error on localhost
The suggestion provided is to set the Domain and Site URL, which I’ve done.

There is also a link to this question: Running Facebook application on localhost
Again, they suggest Site URL. They also talk about app-canvas which is not something I’m using and I don’t see how it would be related to login.

For what it’s worth, before I set the Site URL and Domain, I was getting a different error – one that told me I needed to set the Site URL.

  • 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-18T04:02:55+00:00Added an answer on June 18, 2026 at 4:02 am

    this code worked for me. double check your facebook app id and my site url is set to http:// localhost:8052/ dont really need to set domain name for login thanks

    http://gamma.owlweb.com.ua/index.php/?route=account/register/fb

    <?php
    
    $app_id = "xxx";    $app_secret = "xxx"; 
    $my_url ="http://localhost:3080/abc.php";
    
    session_start();
    
    $code = '';    
    
    if(!isset($_REQUEST["code"])) {
      $_SESSION['state'] = md5(uniqid(rand(), TRUE)); // CSRF protection
      $dialog_url = 
        "https://www.facebook.com/dialog/oauth?client_id=".$app_id
        ."&redirect_uri=".urlencode($my_url)
        ."&state=".$_SESSION['state'];
    
      echo $my_url.'<br/>';
      echo $dialog_url.'<br/>';
      echo("<script> top.location.href='" . $dialog_url . "'</script>");
    } 
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have been unable to fix a problem with Java Unicode and encoding. The
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.

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.