SWAT0 with WebMention as Action Handler

Howdy,

Following message from my reply on 'Photo' (sorry for hijacking attempt!)

I created wiki page on github with example of how we could use
WebMention as Action Handler for object embedded in Activity Stream 2.0 :)

I assume extended WebMention endpoint here (application/ld+json) but for
such *simple case* we could even use currently deployed ones
(application/x-www-url-form-encoded) with proper HtmlForm! I'll add
example later on...

https://github.com/w3c-social/hypermedia-api/wiki/SWAT0

Key part:

{
...
  "@type": ["Activity", "schema:PhotographAction"],
...
  "result": {
    "@type": "schema:Photograph",
    "@id": "https://www.w3.org/wiki/File:20141028_180046.jpg",
    "potentialAction": {
      "@type": "schema:CommentAction",
      "using": {
        "@type": "tmp:WebMention",
        "method": "POST",
        "mediaType": "application/ld+json",
        "tmp:endPoint": "https://webmention.w3.org/",
        "tmp:expects": "schema:Comment"
      }
    }
  }
}

Wiki page has an example of expected Comment POST to endpoint!

One could also get some Photograph data with same hypermedia control
simply with conventional request:

GET /wiki/File:20141028_180046.jpg HTTP/1.1
Host: api.example.com
Accept: application/ld+json
====================================

HTTP/1.1 200 OK
...
Content-Type: application/ld+json

  {
    "@context": ["http://schema.org", { "tmp": "http://ns.tmp/#"}],
    "@type": "Photograph",
    "@id": "https://www.w3.org/wiki/File:20141028_180046.jpg",
    "potentialAction": {
      "@type": "CommentAction",
      "target": {
        "@type": "tmp:WebMention",
        "method": "POST",
        "tmp:endPoint": "https://webmention.w3.org",
        "tmp:expects": "Comment"
      }
    }
  }


Which as you see doesn't require using Activity Streams if someone just
wants to take advantage of such Hypermedia API. IMO yet another reason
to *decouple* as:Activity and Action Handlers, but let's leave this
conversation for separate thread(s)!

:)

Received on Thursday, 30 October 2014 13:49:29 UTC