Displaying Google+ Posts

Posted on Friday, June 08, 2012 11:55 AM by K. Latham

Ever since Google+ came out one of the things I really wanted was a way to display my Google+ posts on my blog. It took a few days of my free time but I was able to create something using the Google+ API to do just that.

You can see my latest Google+ headlines on the Home page of this site in the left column below Twitter widget. I styled it so it would look like the Twitter widget to help keep a consistent looking page.

I quickly coded this with ASP.net(VB). It may not be the most efficient code, but I'm sharing this in the hope it will help point you in the right direction with your own code.

I do know I'll need to find a different method for pulling the JSON from the Google+ API. Pulling live every time will not work in the long run since I'll likely reach an API request limit. I'm looking into some caching possibilities.

Below you'll find my notes and source code snips. If you have any questions, please feel free to contact me over at Google+ or leave a comment below.

Notes

JSON Pull URL (from API):
https://www.googleapis.com/plus/v1/people/(_YOUR_G+_PROFILE_ID)/activities/public?alt=json&maxResults=7&key=(_YOUR_API_KEY_)

maxResults = between 1 and 100, defaults 20

Info I pulled from JSON file for a simple headline display:

items —>   (for each)
      title   (headline or short summary of post)
      updated   (date/time last updated, could have used published)
      url   (url to post)
      actor —> displayName   (poster's name)
      actor —> image —> url   (poster's avatar)
      actor —> url   (url to poster's profile)
      object —> replies —> totalItems   (count of replies)
      object —> plusoners —> totalItems   (count of +1's)
      object —> resharers —> totalItems   (count of reshares)

Google+ API
https://developers.google.com/+/api/
https://developers.google.com/+/api/latest/activities/list

Json.Net
http://json.codeplex.com

Auto hyperlink URL example
http://forums.asp.net/t/1477786.aspx/1

Calculating relative time example
http://stackoverflow.com/questions/11/calculating-relative-time

Code Snips