gpt4 book ai didi

javascript - fb getloginstatus : FB is not defined

转载 作者:行者123 更新时间:2023-12-01 14:15:11 29 4
gpt4 key购买 nike

我收到常见的 JS 错误“ Uncaught ReferenceError :未定义 FB”

关于同一个问题有很多问题,我已经尝试了每个可用的解决方案
stackoverflow 但无济于事。显然,人们有时似乎会遇到这个问题,我一直都在遇到这个问题。谁能发现错误?我暂时没有使用 chnnel url 文件

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<div id="fb-root"></div>
<script type="text/javascript">
window.fbAsyncInit = function()
{
// init the FB JS SDK
FB.init=({
appId : 'xxxxxxxxxxx', // App ID from the App Dashboard
//channelUrl : 'www.something.in/channel.html', // Channel File for x-domain communication
status : false, // check the login status upon init?
cookie : true, // set sessions cookies to allow your server to access the session?
xfbml : true // parse XFBML tags on this page?
}) ;

// Additional initialization code such as adding Event Listeners goes here
} ;



</script>

<script type="text/javascript">
// Load the SDK's source Asynchronously
// Note that the debug version is being actively developed and might
// contain some type checks that are overly strict.
// Please report such bugs using the bugs tool.
(function(d, debug){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all" + (debug ? "/debug" : "") + ".js";
ref.parentNode.insertBefore(js, ref);
}(document, /*debug*/ false));



FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
// the user is logged in and has authenticated your
// app, and response.authResponse supplies
// the user's ID, a valid access token, a signed
// request, and the time the access token
// and signed request each expire
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
alert(uid) ;
} else if (response.status === 'not_authorized') {
// the user is logged in to Facebook,
// but has not authenticated your app
alert("not authorised");
} else {
// the user isn't logged in to Facebook.
alert("NOTHING") ;
}
});

</script>

</body>

</html>

最佳答案

你能让基本的例子工作吗?
https://developers.facebook.com/docs/facebook-login/getting-started-web/
(第 3 节下的全文)

当我包含我自己的代码库 FB 从未定义时,我可以获得加载的基本简单示例。
事实证明,我已经将“Object”原型(prototype)化为有一个名为“copyProperties”的方法。
我将该方法更改为“copyProps”,现在一切正常。因此,如果 Facebook 出于自己的目的对 Object 进行原型(prototype)设计,那么我猜还有其他一些潜在的冲突。

当然,这一定是每个人都说不要原型(prototype) Object 的原因之一,但它很方便!明明是不可数的,所以不要对我大吼大叫。

关于javascript - fb getloginstatus : FB is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14109929/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com