我有以下简单测试页并尝试添加FB登录按钮。这将成为站点站点的一部分,而不是画布应用程序。如果当前用户已经在FB上登录,则显示使用该应用程序的朋友列表,但没有登录按钮。如果当前用户没有在FB上登录,那么我什么也得不到。 任何想法? 这是我的页面...我目前正在localhost下运行它。登录按钮在未登录时未呈现
<body>
<div id="fb-root">
</div>
<!-- Loading of FB SDK -->
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId: '319067848117743', // App ID
channelUrl: 'http://localhost/TestApp/channel.aspx', // Channel File
status: true, // check login status
cookie: true, // enable cookies to allow the server to access the session
xfbml: true // parse XFBML
});
};
// 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 = "http://connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
} (document));
</script>
<!-- Display FB Login Button -->
<script> (function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "http://connect.facebook.net/en_US/all.js#xfbml=1&appId=319067848117743";
fjs.parentNode.insertBefore(js, fjs);
} (document, 'script', 'facebook-jssdk'));</script>
<div class="fb-login-button" data-show-faces="true" data-max-rows="2" data-scope="user_about_me,publish_stream,read_stream">
</div>
</body>
我不确定哪些代码是完全重复的。我试图按照文档。下面的部分是<! - 显示FB登录按钮 - >我在登录插件的页面中找到它。以上代码我在页面中找到它描述了如何包含FB的jscript SDK,这是作为登录插件的先决条件提到的。 关于朋友列表,我正在讨论已经使用该应用程序的朋友的照片。 1)也许我错了,但不管当前用户没有在FB上登录时我应该看到一个按钮,对吧? 2)这就是我所有的代码。 – papadi 2012-01-02 19:49:12
您需要比您发布的更多代码才能使其工作。我没有看到任何代码列出朋友。你能分享一个链接到你的页面,我们可以看看你的代码吗? – DMCS 2012-01-02 19:54:26
感谢您的帮助。也许我的代码是不够的,但这是我现在所拥有的。你在最初的帖子中看到的一切。只需将其复制到一个空的HTM页面即可。 – papadi 2012-01-02 23:31:36