Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

NOTE: This article is 3 years or older so its information may no longer be relevant. Read on at your own discretion! Comments for this article have automatically been locked, refer to the FAQ for more details.
I've noticed a couple of weeks ago that my Google+ auto-posting on my blog stopped working and was giving me a 500 server error. At first I ignored this thinking it's just a temporary outage, but when it persisted for days I decided to investigate it. Turns out Google stopped supporting the Moments API and all of a sudden it stopped working too!

I've written previously on how to share a link to Google+ using the Moments API. This involved calling the moments.insert method to create an App activity. This didn't actually share a link to the user's stream, but it was as close as I could get with Google+.
gplus_warn.png


So since it's no longer possible to do this, what are the alternatives? Well, very few it turns out. With the latest update the Google+ API seems even more locked down than it was before, but as always there is a way to do what I wanted and I'll get to that later, but first lets see the error I started getting.
 Error Message
Error calling POST https://www.googleapis.com/plus/v1/people/me/moments/vault: (500) {
"error": {
"code": 500,
"message": null
}
}


Very nondescript. No explanation, it just doesn't work any more. My response to this was to rip out all of the Google+ code from my blog software. The App Indexing API that's mentioned as a replacement is not an alternative at all since it only works on Android and iOS, it won't work for a web application.

I did find something that I can use, the Share Endpoint. It does require the user to manually click to share so still doesn't work with the rest of my auto-posting functionality, but it is something at least.



Using the Share Endpoint is easy, simply pass the URL you want to share as the url parameter. I ended up doing this with a bit of JavaScript that pops up a new window. This window seems to be resized by Google's code to fit the contents of the share box. This is my code:
 Share Endpoint Javascript
<a href="#" onclick="window.open('https://plus.google.com/share?url=XXXX','_blank','height=500,width=530,menubar=no,status=no,toolbar=no');">Click to share on Google+</a>


Just replace XXXX with whatever you want to share on your Google+ stream. I do urlencode every URL that I pass to this.

Hopefully soon Google will have an API that allows real server-side write access to Google+, but until then we're stuck with these manual options.

-i

Hope you found this post useful...

...so please read on! I love writing articles that provide beneficial information, tips and examples to my readers. All information on my blog is provided free of charge and I encourage you to share it as you wish. There is a small favour I ask in return however - engage in comments below, provide feedback, and if you see mistakes let me know.

If you want to show additional support and help me pay for web hosting and domain name registration, donations, no matter how small, are always welcome!

Use of any information contained in this blog post/article is subject to this disclaimer.
comments powered by Disqus
Other posts you may like...