Gigya Socialize ShareBar API获取点击提供者的提供者名称

时间:2017-04-07 05:43:12

标签: javascript jquery gigya

我在我的项目中使用了Gigya Socialize ShareBar API。我想在任何提供商点击共享弹出窗口中获取提供商名称。

我不能在项目中使用onSendDone函数ref。是否有回调以获取提供者名称?单击它?

以下是Gigya Documention链接:http://developers.gigya.com/display/GD/socialize.showShareBarUI+JS

enter image description here

1 个答案:

答案 0 :(得分:0)

您还可以使用 onShareButtonClicked 事件对提供商的名称执行某些操作。请注意,这不适用于Native登录按钮(移动设备上的Google / Facebook),但如果您在网络上进行操作,那么这应该可以满足您的需求。我附上了一个工作示例(页面上需要一个Gigya API密钥)。

// Create a div for the widget (or use an existing div on your page)
var newShareDiv = document.createElement('div');
newShareDiv.id='ShareDiv';
newShareDiv.setAttribute('style', 'position: absolute; z-index: 1000; margin: 0px auto; margin-top: 10px !important; width: 200px; height: 20px; background-color: yellow; border: 2 px solid red;')
document.body.appendChild(newShareDiv);
//
// Create the UserAction for sharing
var gigyaShareAction = new gigya.socialize.UserAction();
gigyaShareAction.linkBack = 'https://demo.gigya.com';
gigyaShareAction.userMessage = 'Check this out!';
//
// Define shareButtons
var shareButtons = 'Facebook, Twitter, LinkedIn, Messenger, share';
//
// Define the Share Bar Plugin's params object
var shareParams = {
    userAction: gigyaShareAction,
    showCounts: 'none',
    containerID: 'ShareDiv',
    scope: 'both',
    privacy: 'public',
    iconsOnly: true,
    layout: 'horizontal',
    noButtonBorders: false,
    operationMode: 'simpleShare',
    onShareButtonClicked : function(e) {
        console.log(e.shareItem.provider);
    },
    shareButtons: shareButtons // list of providers 
};
//
// Load the Share Bar Plugin:
gigya.socialize.showShareBarUI(shareParams);

这将在控制台中记录所单击的提供商的名称,您也可以创建一个var然后将其发送到某个地方,或者使用该数据触发Google Analytics事件。