我正在使用FB.ui.我需要写回调函数。当用户在我的应用程序中共享图像时,这个回调函数应该由ajax调用触发。当它在fb上共享时,我需要得到它的id,我已经通过$(this).attr('data-id')。
$('.sharepicture').click(function() {
//alert($(this).attr('data-id'));
var obj = {
method: 'feed',
link: TAB_URL + '?app_data=p,' + $(this).attr('data-id'),
picture: ABSOLUTE_URL + '/images/app.jpg',
name: 'myapplication.',
description: 'I\'ve just created a image from collection of pictures in my application . To see my image click on the link above'
};
FB.ui(obj);
});
任何人都可以告诉我如何编写这个回调函数。我试过这样的东西,但它不起作用..
$('.sharepostcard').click(function() {
//alert($(this).attr('data-id'));
var obj = {
method: 'feed',
link: TAB_URL + '?app_data=p,' + $(this).attr('data-id'),
picture: ABSOLUTE_URL + '/images/app.jpg',
name: 'myapplication.',
description: 'I\'ve just created a image from collection of pictures in my application . To see my image click on the link above'
};
FB.ui(obj);
$.ajax({
type: "POST",
url: "http://www.facebook.com/fbml/ajax/dialog/feed",
success: function(data, textStatus, jqXHR) {
alert(data);
}
});
});
如果此处已存在类似帖子,我很抱歉。我确实在搜索它,但我找不到办法。
答案 0 :(得分:0)
FB.ui()允许回调函数作为第二个参数:
FB.ui(obj, function(response) {
if(typeof reponse == 'object' && typeof response['post_id'] != 'undefined') {
msg = 'Message send.';
} else {
msg = 'Failed to send message.';
}
}
);