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:
But I don't even know if it is possible.
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:
But I don't even know if it is possible.
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.
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