gpt4 book ai didi

javascript - Facebook Opengraph自定义fb登录按钮

转载 作者:数据小太阳 更新时间:2023-10-29 03:59:06 26 4
gpt4 key购买 nike

我正在使用 facebook open graph,新的 api,我可以这样做:

<fb:login-button show-faces="true" max-rows="9" perms="email" autologoutlink="true" onlogin="window.location = 'http://www.example.com/facebook/facebook_test/'"></fb:login-button>

但是当我阅读文档时,如果我需要更多选项 http://developers.facebook.com/docs/reference/javascript/FB.login说我可以:

FB.login(function(response) {
if (response.session) {
if (response.perms) {
// user is logged in and granted some permissions.
// perms is a comma separated list of granted permissions
} else {
// user is logged in, but did not grant any permissions
}
} else {
// user is not logged in
}
}, {perms:'read_stream,publish_stream,offline_access'});

但是如果我需要另一个图像作为 fb 按钮,如果我需要其他东西,我找不到怎么做,在 html 的哪一部分我可以调用 FB.login,在标签“脚本”之间?

最佳答案

您需要使用 Javascript SDK为了这。只需将 FB.login 包装到某个函数中,然后在任何需要的地方调用它。例如,如果你想在图片点击时调用它:

<html>
<head>
</head>
<body>
<div id="fb-root"></div>
<script>
//initializing API
window.fbAsyncInit = function() {
FB.init({appId: 'your app id', status: true, cookie: true,
xfbml: true});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>

<!-- custom login button -->
<a href="#" onclick="fblogin();return false;"><img src="images/my_login.png"></a>


<script>
//your fb login function
function fblogin() {
FB.login(function(response) {
//...
}, {scope:'read_stream,publish_stream,offline_access'});
}
</script>

</body>
</html>

关于javascript - Facebook Opengraph自定义fb登录按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3701972/

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