Issue: Attempting to execute FB.login() prior to initiating FB.init()

I have been trying to integrate the Facebook Login Button into my website by using this code:

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
  FB.init({
    appId  : 'myActualId',
    status : true, // check login status
    cookie : true, // enable cookies to allow the server to access the session
    xfbml  : true  // parse XFBML
  });
</script>
<fb:login-button show-faces="false" width="200" max-rows="1"></fb:login-button>

However, when I try to test it, the debug console keeps showing me an error message that says "FB.login() called before calling FB.init()."

To demonstrate the issue, I created a test page which can be viewed here:

I am quite puzzled as to what I might be doing wrong in my implementation. Any guidance or assistance on this matter would be greatly appreciated!

Thank you, Alex

Answer №1

When initializing, ensure you do not pass a non-existing FB app key to avoid the error 'FB.login() called before calling FB.init()'

Double check that you have not made this mistake.

Answer №2

You have duplicated the loading of the Facebook script all.js. Remember to load it only once.

Answer №3

Since I received no response online, I took matters into my own hands and decided to delete the old Facebook app from my developers.facebook.com account. I then created a new app from scratch and started fresh.

Surprisingly, the simple code worked perfectly after that.

Answer №4

In my situation, I encountered a similar issue related to the APP-ID. When attempting to post on Facebook without the proper App-ID, the same problem occurred.

Answer №5

This method has proven successful for me

<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
  FB.init({
    appId  : true,
    status : false, // verify login status
    cookie : false, // activate cookies to allow server access the session
    xfbml  : true  // interpret XFBML
  });
</script>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to implement a double IF condition in JavaScript and Vue?

This particular scenario involves the execution of the runtime function twice - initially, the function operates as expected, and subsequently it swaps template1 with data from template2. We seek assistance in resolving this issue. <template> < ...

Issues with Angular application navigation in live environment

While my website functions perfectly on the development server, I encounter a strange error when I publish it to production on GitHub pages. Visiting the URL (yanshuf0.github.io/portfolio) displays the page without any issues. However, if I try to access y ...

The URIError occurred while attempting to decode the parameter '/December%2015,%' within the express framework

After setting up a middleware using the express framework that handles a URI with a date as a parameter, I encountered a small issue. app.get("/:date",function(req,res){ var result; var myDate=req.params.date if(moment(myDate).isValid()) ...

What are the steps to creating a traffic light that operates automatically?

var RED = "#FF0000"; var YELLOW = "#FFFF00"; var GREEN = "#00FF00"; var DARK_RED = "#380000"; var DARK_YELLOW = "#383800"; var DARK_GREEN = "#003800"; var X_ALL = 150; var Y_RED = 100; var Y_Y ...

What steps should I take to either combine my two functions in my script or ensure they are executed in a specific sequence?

I'm attempting to incorporate a script into an HTML file (based on the solution provided by "skara9" in this post) and customize it to suit my requirements. However, I'm struggling to figure out how to make it work as intended. The script consis ...

Utilize a single array to point to multiple elements

I am curious about the potential to create a unique scenario using JavaScript. Imagine having two arrays: a = [1, 2, 3] b = [4, 5, 6] What if we could combine these arrays into a new array, c, that encapsulates both: c = [1, 2, 3, 4, 5, 6] The intrigui ...

The width of the <ul> element does not properly accommodate the width of the <li> elements during the animation that updates the width of the <li>

I am currently working on implementing a typing animation in React. The li element has an animation that recursively changes its width from 0px to 100%. However, I have noticed that when the width of the li changes, the parent ul does not adjust its width ...

I'm encountering a Type Error message in VS Code terminal stating that converting data to string is not a function. Can someone please help me understand this type error? I am new to Node.js and

const fileSystem = require('fs'); const data = fileSystem.readFileSync('example.txt'); if (data) console.log(data.toString()); console.log('Program Ended'); This is the code I wrote: and this is the error message my terminal ...

"Using Angular and TypeScript to dynamically show or hide tabs based on the selected language on a website

When switching the language on the website, I want to display or hide a specific tab. If the language is set to German, then show the tab; if any other language is selected, hide it. Here's my code: ngOnInit(): void { this.translate.onLangChange.s ...

When a selection is made, the tab changes to a new URL. However, what happens if the tab is closed during the next selection change?

Is there a way for me to detect if the user has closed the browser tab that I opened and redirected to a URL? Here is the code I have so far. It checks if the user changes the value of a select dropdown, then it verifies whether the browser window was alr ...

What is the best way to surround the initial x words within an element with a span tag?

Is there a way to style the first 10 words of a paragraph in a different color when the content is constantly changing? I can't manually add a span in the HTML. My approach involves using JavaScript to iterate through all instances of .overview__text. ...

How to easily toggle multiple elements using jQuery

I'm having trouble getting this block of code to function properly: $("a.expand_all").on("click",function(){ $(this).text('Hide'); $('.answer').each(function () { $(this).slideDown(150, function () { $( ...

conceal the mustard-colored dots within the overlay

Whenever I trigger the link, a modal window pops up, but it comes with an unwanted black background color and yellow dots. How can I prevent the yellow dots from showing up on the overlay? http://jsfiddle.net/y88WX/18/embedded/result/ <nav class="da-d ...

How can I incorporate a personalized checkbox into a column within a React material table?

I'm currently working on a React project where I am using a Material Table. I am trying to figure out how to add a checkbox in a table cell, for example, in the Birth year column instead of just having the year displayed. Can anyone provide guidance o ...

Leveraging HTML tables for input purposes

Just starting out with php, HTML, and mysql. Using HTML tables for the first time here. Created an HTML table filled with data from a MySQL table. Planning to use this table as a menu where users can click on a cell with a specific date. The clicked date ...

Is it possible to display a combination of images and text data using JQUERY/AJAX, when the data is sent as objects or arrays?

I'm struggling to figure out how to handle an object or array sent from a server that contains binary picture and text data using JQUERY/AJAX Here is the server-side setup: const url= require('url'), express = require('express&ap ...

Oops! There seems to be an issue where the 'title' property is being accessed from an undefined source

I've been struggling with this code block for the past few days, and even when attempting to initialize it as an object, I encounter errors. Here is my restaurantForm.ts file import { Component, OnInit } from '@angular/core'; import {Rest ...

Altering the content of a span within a list item using AngularJS

Recently, I encountered some HTML code that looks like this... <ul id="sidemenu" class="wraplist wrapper-menu"> <li class="auto" ng-class='{"active": active == 1 }' ng-click="makeActive(1)"> <span class="arrow material-icons" ...

What could be the reason for the malfunctioning of the where feature in Cloud Firestore?

Looking to create a warning system using discord.js and utilizing Cloud Firestore as the database. The goal is to have a system where when an admin triggers a command, it utilizes the where function to locate all documents containing the userid of the user ...

How can I send a variable into the DOM using AJAX?

Apologies for posting a question earlier about creating a condition for checkbox without proper investigation. It appears that I need to pass my variables here. function setsession(sessionid, action, data) { $("#totalselection").show(); $. ...