【问题标题】:google plus interactive post callbackgoogle plus 互动发帖回调
【发布时间】:2013-10-24 13:41:48
【问题描述】:

我在我的网站上集成了 Google+ 登录,用户可以在此网站上注册,当他们通过 Google+ 互动帖子分享内容时,归于他们的 1 分,所以我需要互动帖子的回调,否则不知道用户是否取消分享。你知道如何从交互式帖子中获得回调吗?代码如下:

<button id="gpShareBtn" class="g-interactivepost" 
data-contenturl="<?php echo _PATHWEB; ?>" 
data-clientid="<?php echo _GPCLIENTID ?>" 
data-cookiepolicy="single_host_origin" 
data-prefilltext="text" 
data-calltoactionlabel="TRY_IT" 
data-calltoactionurl="<?php echo _PATHWEB; ?>" 
data-gapiscan="true" 
data-onload="true" 
data-gapiattached="true">gpshare</button>

提前致谢

【问题讨论】:

  • 您真的应该在 HTML 上下文中使用的任意数据周围使用htmlspecialchars()

标签: javascript google-plus


【解决方案1】:

您实际上可以通过向 JSON 添加一个 onshare 键(在本例中为 HTML 标记上的数据属性),使用该插件获取共享过程的每个步骤的状态,我使用 render 方法制作它JavaScript SDK 如下:

  var shareOptions = {
    contenturl:         "http://example.com",
    clientid:           "xxx.apps.googleusercontent.com",
    cookiepolicy:       "single_host_origin",
    calltoactionlabel:  "GO",
    calltoactionurl:    "http://example.com/go",
    onshare: function(response){
      // These are the objects returned by the platform
      // When the sharing starts...
      // Object {status: "started"}
      // When sharing ends...
      // Object {action: "shared", post_id: "xxx", status: "completed"} 
    }
  };

  gapi.interactivepost.render('some_div_id', shareOptions);

我认为你也可以对 HTML 标签做同样的事情。

【讨论】:

  • 您是如何得知 onshare: 功能的?
  • shareend 或类似的东西怎么样。分享结束后如何跟踪
  • 取消时{action: 'cancelled', status: 'completed'}
  • 我对 google plus 的 JS 文件进行了逆向工程。
【解决方案2】:

目前没有可用于交互式帖子的回调。对此有一个开放的功能请求,您可以加注星标以表示您的兴趣并获得更新:

https://code.google.com/p/google-plus-platform/issues/detail?id=521

【讨论】:

  • 谢谢,可惜google没有想到这一点,几乎每个动作都应该有回调,尤其是这种情况
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-09-06
  • 1970-01-01
  • 1970-01-01
  • 2013-06-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多