- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 Facebook 页面选项卡应用程序,在刷新页面后才能正确加载。一个多星期以来,我一直在努力解决这个问题,但我已经无计可施了。
代码如下:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script src="https:////connect.facebook.net/en_US/all.js"></script>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '***************', // App ID
channelURL : '//www.********.com/**********/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
oauth : true, // enable OAuth 2.0
xfbml : true // parse XFBML
});
// Additional initialization code here
};
// Load the SDK Asynchronously
(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));
</script>
<script type="text/javascript">
$(document).ready(function(){
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
//User Logged In
}
else if (response.status === 'not_authorized') {
//Log User Into App
}
else
{
top.location = "http://www.facebook.com";
}
});
});
</script>
就像我说的,如果在 FB.getLoginStatus(function(response) {
之后立即添加类似 alert("Test")
的内容,它不会弹出第一个页面加载,但在页面刷新后加载。
有人可以帮我指明正确的方向吗?
谢谢,弗雷德
最佳答案
首先,您要同步和异步加载 SDK。删除同步线。那么所有与 FB 相关的行都应该在 window.fbAsyncInit 中。在 sdk 完全加载之前,您无法订阅事件。
关于javascript - FB.getLoginStatus 需要在触发前刷新页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8071781/
我有问题,我想在那个应用程序中使用 FB 好友列表,我可以通过 FB SDK 检索 FB 好友列表...... 最佳答案 FB SDK 支持通过以下方式调用 FB graph api: - (FBRe
我有一个简单的视频,最后包含一个共享按钮,当用户单击共享按钮时,会打开一个带有社交媒体图标的模态框,例如用户可以将视频共享到 Facebook,现在我想要来自 Facebook 的回调响应视频分享后。
我收到常见的 JS 错误“ Uncaught ReferenceError :未定义 FB” 关于同一个问题有很多问题,我已经尝试了每个可用的解决方案 stackoverflow 但无济于事。显然,人
你好,我想知道如果我创建了一个 Facebook 页面(没有普通用户)是否可以获得 FB APP_ID,或者这个 ID 仅用于应用程序?谢谢 最佳答案 如果您是 Facebook 用户,请登录您的 I
我有一个客户已经有一个与他们自己的网站相关联的 Facebook 页面。我最终说服他们将开放图标签集成到他们的页面中,因为当任何人点击他们网站上的 Facebook Like 按钮时,它在 Faceb
我的问题很简单,FB Messenger如何知道谁与其他FB应用程序连接,我的意思是在iOS中,应用程序使用sandBox,但是当您在“正常”应用程序中作为“xy”连接并且打开Messenger时它会
这段最近工作完美的代码在与 FB JS API 一起使用时不再正常工作: placeOrder : function(order_info) { var onOrderPlaced = funct
我正在尝试从我使用以下代码的 facebook 广告 api 获取广告系列列表 $account = new AdAccount('act_' . $account_id);
我的控制台中有这条消息 FB.getLoginStatus() called before calling FB.init(). 我的代码 // Load the SDK Asyn
我知道有很多关于 Facebook 访问 token 的问题及其造成的痛苦,但尽管进行了大量实验并阅读了许多令人沮丧的模糊博客文章(FB 和其他),我仍在努力获得明确的答案根据我的需要。让我简要地分解
我查看了有关 stackoverflow 的各种文档和问题,但仍然无法弄清楚为什么以下代码不会触发任何 FB.Event.subscribe 事件 getLoginStatus。 (fun
我想要实现的是: 我有一个简单的 Facebook 分享按钮,取自 Facebook 开发人员。站点: 现在我在开始正文标记之前添加了同样取自 facebook 的 facebook 应用程序代码:
我想检查用户是否使用 Facebook JavaScript JDK 和 jQuery 登录 facebook。但即使超时 10 秒,我也会收到此错误消息: 在调用 FB.init() 之前调用 FB
我有一个正在编写的网站。 javascript SDK 有效 php SDK 有效 HTML 如下所示: 带有 fb-registration div 的注册页面 带有 fb-login-button
我正在尝试检查用户是否已使用我的应用登录,但我收到了 FB.getLoginStatus() called before calling FB.init(). 控制台出错。 setSize似乎有效(虽
FB.api 在 FB.init 之后立即调用时不起作用。这是我使用的代码片段: window.fbAsyncInit = function() { FB.init({ appId : w
我希望用户在单击我网页上的几个按钮之一时能够将一些图像发布到他们的 Facebook 页面。 FB.getLoginStatus(function(response) { if ( respon
我正在使用 PFFacebookUtils.logInWithPermissions 登录我的应用程序,但是,第一次登录实际登录工作正常,但出现 FB 错误 code = 2500 An active
我全新的工作充满了美妙和可怕的惊喜。这项工作最有趣的部分之一是增强、加速、使一切规模化的意愿。今天,第一个真正的问题。事情是这样的:我们得到最多 20 个列表元素,每个元素都显示自己的 Faceboo
我在这里使用 asp.net web 应用程序,我在我的网页中使用 2 个 facebook 插件。 Facebook 赞 Facebook 分享 对于 facebook 分享: Faceboo
我是一名优秀的程序员,十分优秀!