最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - google plus interactive post callback - Stack Overflow

programmeradmin3浏览0评论

I integrated Google+ Sign-In on my website, users can register on this site and when they share something via Google+ interactive posts, is attributed to their 1 point, so I need a callback from interactivepost otherwise not know if users cancel the sharing. Do you know how to get a callback from interactive post? The code is as follows:

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

Thanks in advance

I integrated Google+ Sign-In on my website, users can register on this site and when they share something via Google+ interactive posts, is attributed to their 1 point, so I need a callback from interactivepost otherwise not know if users cancel the sharing. Do you know how to get a callback from interactive post? The code is as follows:

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

Thanks in advance

Share Improve this question edited Oct 24, 2013 at 13:52 BrettJ 6,8511 gold badge25 silver badges26 bronze badges asked Oct 24, 2013 at 13:41 EasyintEasyint 433 bronze badges 1
  • You should really be using htmlspecialchars() around arbitrary data used in the context of HTML. – Brad Commented Oct 24, 2013 at 13:59
Add a ment  | 

2 Answers 2

Reset to default 8

You can actually get the status of each step of the sharing process with that plugin by adding an onshare key to the JSON (in this case a data attribute on the HTML tag) I made it using the render method of the JavaScript SDK as following:

  var shareOptions = {
    contenturl:         "http://example.",
    clientid:           "xxx.apps.googleusercontent.",
    cookiepolicy:       "single_host_origin",
    calltoactionlabel:  "GO",
    calltoactionurl:    "http://example./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: "pleted"} 
    }
  };

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

And I think you can do the same thing with the HTML tags as well.

Currently there is no callback available for interactive posts. There is an open feature request for this that you can star to show your interest and get updated:

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

发布评论

评论列表(0)

  1. 暂无评论