我有facebook应用程序为我的网站和facebook连接工作良好。我有在用户的墙选项,但张贴在墙上发生作为一个弹出窗口,大多数浏览器都自动禁用弹出。所以墙上的帖子不工作,因为我想要它,因为大多数人不启用弹出窗口。有没有办法使这个帖子不弹出。
我为fb connect使用的代码是
<script>
window.fbAsyncInit = function()
{
FB.init({
appId : '',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true , // parse XFBML
oauth : true // Enable oauth authentication
});
FB.login(function(response)
{
if (response.authResponse)
{
FB.api('/me/feed', 'post',
{
message : "",
link : '',
picture : "",
name : '',
description : ''
},
function(response) {
showLoader(false);
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response.id);
}
});
}
}, { scope : 'publish_stream' });
};
</script>
<!-- FACEBOOK -->
<div id="fb-root"></div>
<script>
(function() {
var e = document.createElement('script');
// replacing with an older version until FB fixes the cancel-login bug
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
//e.src = 'scripts/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
<!-- END-OF-FACEBOOK -->
这不是打开弹出窗口的张贴(FB.api
是一个后台方法,它从不打开弹出窗口)-但FB.login
调用。
正如文档中提到的,这个方法不应该在页面加载时调用,而应该在显式的用户交互(例如单击登录按钮)时调用。当前浏览器中的弹出窗口拦截器在其默认配置中不会阻止用户交互时出现的弹出窗口。
如果这对您来说还不够好,那么您可以使用登录对话框的直接URL版本,这将引导用户登录Facebook并在登录后返回您的页面:https://developers.facebook.com/docs/howtos/login/client-side-without-js-sdk/#step2