简体   繁体   English

Gigya Socialize ShareBar API在点击提供程序上获取提供程序名称

[英]Gigya Socialize ShareBar API get provider name on click providers

I am using the Gigya Socialize ShareBar API in my project. 我在我的项目中使用了Gigya Socialize ShareBar API。 I want to get the Provider name on any provider click in sharing popup. 我想在共享弹出窗口中单击任何提供程序时获取提供程序名称。

I can't use onSendDone function ref in the project. 我不能在项目中使用onSendDone函数ref。 Is there callback to get the provider name on click it? 是否有回调以获取提供程序名称(单击它)?

Here is the Gigya Documention link: http://developers.gigya.com/display/GD/socialize.showShareBarUI+JS 这是Gigya Documention链接: http : //developers.gigya.com/display/GD/socialize.showShareBarUI+JS

在此处输入图片说明

You can also use the onShareButtonClicked event to do something with the name of the provider. 您还可以使用onShareButtonClicked事件对提供者的名称进行操作。 Note that this will not work for Native login buttons (Google/Facebook on mobile) but if you are doing on the web then this should do what you need. 请注意,这对于本机登录按钮(移动设备上的Google / Facebook)不起作用,但是如果您在网络上进行操作,那么这应该可以满足您的需求。 I am attaching a working example (requires a Gigya API key on the page). 我正在附上一个有效的示例(需要页面上的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);

This will log to the console the name of the Provider that was clicked, you can alternatively create a var and then send it somewhere, or fire a Google Analytics event with the data. 这样会将单击的提供程序的名称记录到控制台,您也可以创建一个变量,然后将其发送到某个地方,或者使用数据触发Google Analytics(分析)事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM