我正在尝试将facebook用户名设置为flashvars,然后将其传递给swf,如下所示:
var flashvars = {
AppID: "my_id",
Name: ""
};
function init()
{
FB.init({appId:APP_ID, status: true, cookie: true});
FB.getLoginStatus(handleLoginStatus);
}
function handleLoginStatus(response)
{
if (response.session) { //Show the SWF
FB.api('/me/', function(response){ alert(response.name); flashvars['Name'] = response.name;});
swfobject.switchOffAutoHideShow();
swfobject.embedSWF("main.swf", "ConnectDemo", "640", "480", "9.0", null, flashvars, null, {name:"ConnectDemo"});
} else { //ask the user to login
var params = window.location.toString().slice(window.location.toString().indexOf('?'));
top.location = 'https://graph.facebook.com/oauth/authorize?client_id='+APP_ID+'&scope='+PERMS+'&redirect_uri=' + REDIRECT_URI + params;
}
}但是名称flashvars显示为空白,有其他方法可以做到这一点吗?
发布于 2011-05-26 03:37:57
SWF ()是异步的,因此您需要等待FB.api显示,直到它做出响应。
if (response.session) { //Show the SWF
FB.api('/me/', function(response) {
swfobject.switchOffAutoHideShow();
swfobject.embedSWF("main.swf", "ConnectDemo", "640", "480", "9.0", null, flashvars, null, {name:response.name});
});
}https://stackoverflow.com/questions/6129848
复制相似问题