And*_*ndy 5 javascript facebook dialog facebook-javascript-sdk
我正在使用Facebook发送对话框向朋友发送消息.正如此处所述:https://developers.facebook.com/docs/reference/dialogs/send/并且正在使用类似于Facebook示例中的链接:
https://www.facebook.com/dialog/send?app_id=123050457758183&name=People%20Argue%20Just%20to%20Win&link=http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html&redirect_uri=http://www.example.com/response
在我指定的页面上,redirect_uri我正在显示文字说:"您的邮件已被发送".但是,即使你在Facebook对话框中点击了取消,我也意识到你会看到这个页面.
有没有办法确定是否点击了保存或取消?
更新:我找到了一个使用FB.ui方法的解决方法,它解决了我遇到的直接问题. 我仍然有兴趣知道是否有人使用如上所述的发送对话链接有更好的解决方案.
我通过使用Facebook的Javascript SDK的FB.ui方法找到了解决方法.
FB.ui({
method: 'send',
name: 'People Argue Just to Win',
link: 'http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html,
display: 'popup'
});
Run Code Online (Sandbox Code Playgroud)
NB显示必须设置为弹出才能使其正常工作!
因为它不需要a redirect_uri,所以知道是否点击了保存或取消的问题不是问题.但是,如果您确实想知道这一点,则可以访问响应对象:
FB.ui({
method: 'send',
name: 'People Argue Just to Win',
link: 'http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html,
display: 'popup'
},
function(response) {
if (response){
// save has been clicked
} else {
// cancel has been clicked
}
});
Run Code Online (Sandbox Code Playgroud)
小智 5
对Andy的响应的小补充:响应对象没有提供有关已发送内容的实际信息(在控制台中返回[]),但仅仅响应对象的EXISTENCE表示已按下"SEND"按钮
FB.ui(obj, function (param) {
if (param) {
// The "SEND" button has been pressed
}
else{
// The "Cancel" button has been pressed
}
Run Code Online (Sandbox Code Playgroud)