Google+交互式帖子-如何为按钮添加回调

Google+ interactive post - How to add callbacks for buttons?

本文关键字:按钮 添加 回调 交互式 Google+      更新时间:2023-09-26

我使用的是Google+交互式发布功能,其中发布窗口提供了closeshare按钮。如何检测用户单击了哪一个?我在他们的JavaScript API中找不到回调-是否可以添加自定义回调

当前没有提供您想要的回调类型。按钮的唯一回调是通过交互式发布按钮处理用户登录的回调,该按钮在响应中提供访问令牌和其他信息。听回拨会让你知道他们是否授权了你的应用程序,但不一定会执行共享。

使用下面提供的onShare选项

var deferred = $q.defer();
var options = {
    clientid: GooglePlus.getClientId(),
    contenturl: data.shareURL,
    calltoactionlabel: "SHARE",
    calltoactionurl: data.shareURL,
    cookiepolicy: "single_host_origin",
    prefilltext: "",
    callback: function(response){},
    onshare: function(response){ 
        if(response.status === 'completed') {
            if(response.action && response.action === 'cancelled') {
                deferred.reject( response );
            } else {
                deferred.resolve( response );
            }
        }
    }
};
$window.gapi.interactivepost.render($event.target, options);