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

| Views: 997
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

Have comments or feedback on what I wrote? Please share them below! Found this useful? Consider sending me a small tip.
comments powered by Disqus
Other posts you may like...