W3C home > Mailing lists > Public > public-socialweb@w3.org > October 2014

SWAT0 with WebMention as Action Handler

From: ☮ elf Pavlik ☮ <perpetual-tripper@wwelves.org>
Date: Thu, 30 Oct 2014 14:47:17 +0100
Message-ID: <54524165.5080603@wwelves.org>
To: public-socialweb@w3.org
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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:26:13 UTC