0

I am going to host a simple HTML/JS game on my personal site and would like to give players an ability to post their score into Google Plus like in Doodles:

enter image description here

But I don't even know if it is possible.

Nakilon
  • 34,866
  • 14
  • 107
  • 142

2 Answers2

1

This can be done as an interactive post.

The general idea is that you would provide a button or link that says "share your score" or something similar. This would bring up the interactive post that you have described above. That interactive post would contain a link to a page containing the user's score as part of the text and the image to display (so Google's bot can scrape that info), and could contain some pre-filled text for the user to edit or accept and a "call to action" button encouraging people to play the game.

For example, your button might look something like this:

<button
  class="g-interactivepost"
  data-contenturl="https://example.com/userScore?gameid=123456789"
  data-clientid="xxxxx.apps.googleusercontent.com"
  data-cookiepolicy="single_host_origin"
  data-prefilltext="I had fun with this game! You can play it too!"
  data-calltoactionlabel="PLAY"
  data-calltoactionurl="http://example.com/playGame">
  Share your score
</button>

You need to use the developer console to get a clientid for this webapp if you don't already have one. The page also needs this boilerplate text just before the closing tag:

<script type="text/javascript">
  (function() {
   var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
   po.src = 'https://apis.google.com/js/client:plusone.js';
   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
 })();
</script>

See the page on interactive posts for details.

You would also need a userScore page that contained snippet markup with the relevant game information for this specific game.

Nakilon
  • 34,866
  • 14
  • 107
  • 142
Prisoner
  • 49,922
  • 7
  • 53
  • 105
  • So I edit on the fly (because it would make debugging a thing, unknown to me, even harder) my `http://example.com/`, place the button, set two attribute urls to the same frontpage, put generated (and allowed to accept requests from `http://*.example.com/*`) API Key instead of xxxxx, execute code -- it spawns two iframes. I click the button and get: `401. That’s an error. Error: invalid_client Bad request.` – Nakilon Jul 11 '14 at 15:42
-1

According to this official source, Google plus dont let you do that.

You even can try to use the schema.org like that

?redirect_url=http://YOUR-WEBSITE.com&img=YOUR-IMAGE.jpg&description=YOUR-SCORE&title=YOUR-GAME
Rémi Delhaye
  • 794
  • 3
  • 16