我正在使用forge facebook api打开一个提要对话框以将图像发布到用户墙。如果用户点击'Cancel‘而不是'Share',则仍会触发成功回调。如果用户单击close (X)按钮,错误回调将被正确触发。
forge.facebook.ui(
{
method: 'feed',
link: link,
picture: model.get('file').url,
name: name,
caption: caption,
description: 'Lorem Ipsum'
},
function(response) {
// Called when user clicks cancel.
forge.notification.create(
'Great!',
'Item has been posted to your wall',
function() {
},
function(error) {
forge.logging.error(JSON.stringify(error));
}
);
},
function (e) {
// Called when user closes dialogue but not on cancel.
forge.logging.info('facebook failed: ' + JSON.stringify(e));
}
);
发布于 2012-12-06 02:12:52
我倾向于同意这是意想不到的行为-然而,它在Facebook提供的几个SDK中是一致的,并且已经有一段时间了,所以我们按原样传递它。
如果用户点击对话框左上角的x
,将调用您的错误回调。如果用户取消对话框,则会调用您的成功回调,回调参数为{}
。
我建议用下面这样的代码来检查这个案例:
forge.facebook.ui({
method: 'feed',
link: link,
},
function (response) {
if (JSON.stringify(response) === "{}") {
handleCancel();
} else {
handleSuccess(response);
}
}
function (error) {
handleError(error);
}
);
https://stackoverflow.com/questions/13559716
复制相似问题