简体   繁体   中英

Gigya Socialize ShareBar API get provider name on click providers

I am using the Gigya Socialize ShareBar API in my project. I want to get the Provider name on any provider click in sharing popup.

I can't use onSendDone function ref in the project. 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

在此处输入图片说明

You can also use the onShareButtonClicked event to do something with the name of the provider. 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. I am attaching a working example (requires a Gigya API key on the page).

// 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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