我正在使用facebook open graph,new 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,是在标签'脚本'之间? / p>
答案 0 :(得分:30)
您需要使用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>