2012-06-27

Let's take a Moment...

So Google has released a preview version of a new feature for Google+ called the History API... it's essentially the mechanism third party applications will use to push content into a users G+ stream... like Facebook's OpenGraph only more Googley. The details are here.

The part that is of interest to me are the underlying details of how the History API is put together. Specifically, third parties use the API by posting "Moments" to the G+ endpoint. A Moment is a JSON structure that looks like...


{
  "type": "http://schemas.google.com/ViewActivity",
  "target": {
    "url": "http://www.youtube.com/watch?v=6y_xKVSRAy8"
  }
}

Does that look familiar? It should. The basic structure and abstract model for a "Moment" is virtually identical to an Activity in the Activity Streams format, but Google chose to use a modified format that, unfortunately, is not directly compatible with Activity Streams. This is unfortunate, but let's go with this for a few minutes...

Within the Moments structure, the "actor" is implied by the authentication context. The API requires OAuth and the OAuth token is tied to a particular user. The above statement implies that the authenticated user is the one who viewed the referenced YouTube video. The "type" property identifies the "verb". Google's eventual intent is to defer to verb statements defined within schema.org rather than those defined as part of the core Activity Streams schema.  The "target" identifies the thing that was acted upon... The structure is fairly simple and straightforward. That part is good.

That said, a regular Activity Statement (already supported by Google+'s primary API) could have easily worked and would have been just as straightforward. For instance, suppose we went with a slightly modified form that relaxed the requirement that "actor" MUST be specified and that when doing so, the actor is implied by context... We would have...

{
  "verb": "http://schemas.google.com/ViewActivity",
  "object": {
    "url": "http://www.youtube.com/watch?v=6y_xKVSRAy8"
  }
}

I do not understand why a new alternative and incompatible structure was needed for this. Why diverge from a standard that Google helped create? It doesn't make sense.

2 comments:

  1. Hi James, there are a lot of issues we encountered here.

    Will, myself and others looked at shoehorning the data payload into AS format and we found a number of problems. The specific examples were "Bookmark" where you have a user-specified name and the name of the target. The other issue is that AS verb metadata would get dumped into the same namespace as the other attributes.

    This is a developer release, so we're really looking forward to feedback. Thanks for taking a look and we'll definitely be in touch.

    ReplyDelete
  2. Bookmark is certainly an odd case within the Activity Streams schema and I've never really been happy with the way it was defined. Perhaps that's one we need to revisit before the schema is completed. That said, so far looking through the published documentation you guys have on the website, i'm not seeing what the issues could have been. It would be excellent if y'all could jump in on the activity streams list and provide a solid explanation of the thought process. If there's something fundamental that's missing in AS, it would be great to know.

    ReplyDelete