Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google plus interactive post callback

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

like image 392
Easyint Avatar asked Dec 19 '22 22:12

Easyint


1 Answers

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.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);

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

like image 50
Antonio Payne Avatar answered Dec 22 '22 10:12

Antonio Payne