我正在尝试在 FB.ui(发送对话框)中执行回调函数。它在加载 FB.ui 时同时调用,但我想在按下“发送”或“取消”按钮后执行回调函数。可以实现吗?
function callback(response) {
alert('message was sent');
}
FB.ui({
method: 'send',
name: 'Dialog',
link: 'http://***.com',
redirect_uri: '****',
description: '***',
picture: '***',
to: userId
},
callback(response)
);
最佳答案
回调需要一个函数作为参数。在这里,您实际上是在调用该函数。
Facebook 实际上会调用您随响应传递给它的函数。
与其将“callback(response)”作为回调参数传递,不如像这样传递“callback”:
function callback(response) {
alert('message was sent');
}
FB.ui({
method: 'send',
name: 'Dialog',
link: 'http://***.com',
redirect_uri: '****',
description: '***',
picture: '***',
to: userId
},
callback
);
关于javascript - Facebook JavaScript 发送对话框,回调函数不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9176264/