Google: Adding Google Plus button to your content pages

0 Comments

Perhaps the best documented out of the social share buttons.

It's quite straight forward if you read the API page.

A simple example with asynchronous loading would be:

01.<g:plusone></g:plusone>
02. 
03.<script type="text/javascript">
04.(function() {
05.  var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
07.  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
08.})();
09.</script>

That's it!

If you want to configure it, the options are listed on the page under Configuration.

Detecting Plus One Click Event

This is incredibly easy compared to Facebook's API!

1.<g:plusone callback="googleplus_callback"></g:plusone>

Now in your Javascript function, just check if the state is "on".

1.function googleplus_callback(response) {
2.  alert(response['state'] == 'on');
3.}

Ah, so developer friendly!

4e31e0a74eb3d

See my other posts about sharing buttons for Facebook and Twitter.

Sources

 
Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog