我正在iframe中创建一个facebook应用程序。这个页面大部分是工作的,但是我想在页面中使用当前登录的用户名,用于自定义消息传递等。
我像这样加载FB库:
<div id="fb-root"></div>
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript" >
FB.init({
appId : '106832082707477',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.getLoginStatus(function(response) {console.log("FB.getLoginStatus=" + response.status)});
</script>
我目前有沙盒模式的网页,但4人中有两人收到FB.getLoginStatus=已连接,而另外两个FB.getLoginStatus=未连接.
对于那些没有联系的人,当我打电话的时候FB.api公司,它返回“undefined”作为用户名:
function testFBLoggedIn() {
//http://developers.facebook.com/docs/reference/api/user
FB.api('/me', function(response) {
alert(response.first_name);
}
}
除了抛出一个允许框,有没有人对如何一致地获得facebook用户名的控制有什么想法?
谢谢。