【问题标题】:Gigya Socialize ShareBar API get provider name on click providersGigya Socialize ShareBar API 获取点击提供商的提供商名称
【发布时间】:2017-04-19 23:13:51
【问题描述】:

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

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

这是 Gigya 文档链接:http://developers.gigya.com/display/GD/socialize.showShareBarUI+JS

【问题讨论】:

    标签: javascript jquery gigya


    【解决方案1】:

    您还可以使用 onShareButtonClicked 事件对提供者的名称进行操作。请注意,这不适用于本机登录按钮(移动设备上的 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);
    

    这会将被点击的 Provider 的名称记录到控制台,您也可以创建一个 var 然后将其发送到某个地方,或者使用数据触发 Google Analytics 事件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-14
      • 1970-01-01
      • 2016-07-06
      • 1970-01-01
      • 2016-10-24
      • 2012-02-22
      • 2011-10-10
      相关资源
      最近更新 更多