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 7430831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:12:09+00:00 2026-05-29T09:12:09+00:00

I am trying to implement Facebook Login functionality to my website. I followed the

  • 0

I am trying to implement Facebook Login functionality to my website. I followed the instructions, and have entered the code correctly as far as I can see it. Here is my code:

<div id="fb-root"></div>
<div class="fb-login-button" data-scope="email" >Login with Facebook</div>
<script>
    window.fbAsyncInit = function() {
      FB.init({
        appId      : 'MY_APP_ID',
        status     : true, 
        cookie     : true,
        xfbml      : true,
        oauth      : true,
      });
    };
    (function(d){
       var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
       js = d.createElement('script'); js.id = id; js.async = true;
       js.src = "//connect.facebook.net/en_US/all.js";
       d.getElementsByTagName('head')[0].appendChild(js);
     }(document));

If you see something I don’t, please let me know. This should work as far as I can tell (after following facebook’s instructions).

Thanks for the help in advance.

  • 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-05-29T09:12:10+00:00Added an answer on May 29, 2026 at 9:12 am

    I’m assuming you’re replacing MY_APP_ID with your actual ID, and closing your script section. If that’s not the problem, I’d need to see more of your HTML source besides the snippet you provided.

    Here is an example html page source, that has a button to login/logout, depending on whether you’re currently logged in or not. It also displays the logged in users profile pic when logged in. It’s an example I made based on the facebook docs, but I’ve tested it and it works. Obviously you’ll need to replace the app id with an actual app id.

    <html>
    <head>
      <title>Hello World</title>
      <meta name="viewport" content="initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    </head>
    <body>
    
    <!-- Display a login if you're coming to the app from outside of facebook -->
     <div id="login">
     <p><button onClick="loginUser();">Login</button></p>
     </div>
    
     <div id="logout">
       <p><button  onClick="FB.logout();">Logout</button></p>
     </div>
    
    <script>
       function loginUser() {    
         FB.login(function(response) { }, {scope:'email'});     
       }
    </script>
    
    <p>Misc page content here...</p>
    
    <!-- Initialize the fb javascript SDK -->
    <script>
      window.fbAsyncInit = function() {
        FB.init({ appId: '1234567...', 
                  status: true, 
                  cookie: true,
                  xfbml: true,
                  oauth: true});
        FB.Event.subscribe('auth.statusChange', handleStatusChange);  
      };
    </script>
    
    <!-- Callback triggered when the user authenticates -->
     <script>
      function handleStatusChange(response) {
          document.body.className = response.authResponse ? 'connected' : 'not_connected';
          if (response.authResponse) {
            console.log(response);
    
            updateUserInfo(response);
          }
        }
     </script>
    
    <!-- fb javascript SDK import -->
    <div id="fb-root"></div>
    <script>
      (function() {
        var e = document.createElement('script'); e.async = true;
            e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
            document.getElementById('fb-root').appendChild(e);
            }());
    </script>
    
    <!--Display the user's face when they log in -->
    <div id="user-info"></div>
     <script>
       function updateUserInfo(response) {
         FB.api('/me', function(response) {
           document.getElementById('user-info').innerHTML = '<img src="https://graph.facebook.com/' + response.id + '/picture">' + response.name;
         });
       }
     </script>
    
    <!-- This style sheet changes the name of the body to reflect logged in status, thereby
         cueing to the login logout buttons which one should be visible -->
    <style>
      body.connected #login { display: none; }
      body.connected #logout { display: block; }
      body.not_connected #login { display: block; }
      body.not_connected #logout { display: none; }
    </style>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement Facebook Connect functionality into a website that I am
I'm trying to implement Facebook Connect on a website with .NET MVC using C#.
I am trying to implement facebook like functionality using android webview. It is working
I have been trying to implement the Facebook Feed Dialog as follows <a href=http://www.facebook.com/dialog/feed?app_id=12345678&redirect_uri=http://example.com&link=http://example.com&message=Hi+wassup!>
I'm trying to implement a similar functionality to Facebook's thumbnail preview. The idea is,
I was trying to implement facebook logout functionality for my django app. In my
Hi i was trying to implement facebook login for my django app using django-facebook
I'm trying to implement the Facebook login for one of my applications and the
I'm trying to implement the 1.6 Mobile Facebook API ( http://code.google.com/p/facebook-actionscript-api/downloads/detail?name=GraphAPI_Mobile_1_6.swc ) into an
I am trying to implement Facebook in my iPhone app and I have successfully

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.