Skip to content

Sample ActivityPub json snippets

qwazix edited this page Sep 4, 2019 · 10 revisions

Writefreely new post federating out to followers

{
  "@context": [
    "https://www.w3.org/ns/activitystreams",
    {
      "commentsEnabled": "sc:Boolean",
      "sc": "http://schema.org#"
    }
  ],
  "type": "Create",
  "id": "http://writefreely.xps/api/posts/3y2vettm5r",
  "actor": "http://writefreely.xps/api/collections/qwazix",
  "published": "2019-08-08T16:02:49.613334687Z",
  "to": [
    "https://www.w3.org/ns/activitystreams#Public"
  ],
  "cc": [
    "http://floorb.qwazix.com/actor/"
  ],
  "object": {
    "type": "Article",
    "id": "http://writefreely.xps/api/posts/3y2vettm5r",
    "published": "2019-08-08T16:02:49.613334687Z",
    "inReplyTo": null,
    "url": "http://writefreely.xps/this-is-post-number-3",
    "attributedTo": "http://writefreely.xps/api/collections/qwazix",
    "to": [
      "https://www.w3.org/ns/activitystreams#Public"
    ],
    "cc": [
      "http://floorb.qwazix.com/actor/"
    ],
    "name": "This is post number 3",
    "content": "\\u003cp\\u003epost 3\\u003c/p\\u003e\n",
    "contentMap": {
      "en": "\\u003cp\\u003epost 3\\u003c/p\\u003e\n"
    },
    "tag": [],
    "commentsEnabled": false
  }
}

Mastodon boost

{
    "id": "https://mastodon.social/users/qwazix/statuses/102565077202414254/activity",
    "type": "Announce",
    "actor": "https://mastodon.social/users/qwazix",
    "published": "2019-08-05T15:27:58Z",
    "to": [
        "https://www.w3.org/ns/activitystreams#Public"
    ],
    "cc": [
        "https://cybre.space/users/tzo",
        "https://mastodon.social/users/qwazix/followers"
    ],
    "object": "https://cybre.space/users/tzo/statuses/102564367759300737",
    "atomUri": "https://mastodon.social/users/qwazix/statuses/102565077202414254/activity"
}

Mastodon boost of writefreely post

      {
         "actor" : "https://cybre.space/users/qwazix",
         "atomUri" : "https://cybre.space/users/qwazix/statuses/102687762547102985/activity",
         "cc" : [
            "https://mixt.qwazix.com/api/collections/qwazix",
            "https://cybre.space/users/qwazix/followers"
         ],
         "id" : "https://cybre.space/users/qwazix/statuses/102687762547102985/activity",
         "object" : "https://mixt.qwazix.com/api/posts/ixnx0j5awp",
         "published" : "2019-08-27T07:28:28Z",
         "to" : [
            "https://www.w3.org/ns/activitystreams#Public"
         ],
         "type" : "Announce"
      },

This is what we (pherephone) send out when we want to follow a writefreely instance. It seems to work

Headers

Rec'd! "POST /api/collections/qwazix/inbox HTTP/1.1
Host: writefreely.xps
Accept-Charset: utf-8
Accept-Encoding: gzip
Connection: Keep-Alive
Content-Length: 222
Content-Type: application/ld+json; profile="https://www.w3.org/ns/activitystreams"
Date: Tue, 13 Aug 2019 11:18:35 GMT
Digest: SHA-256=nZV7ldUDtA5yCqFGbjA+5t0hQeDCce5vFDJYL8aAVOo=
Signature: keyId="",algorithm="rsa-sha256",headers="(request-target) date host digest",signature="HyObWRgCkG2j21rbNQoF860/kEiwoTmb6hMiJIy0zR94PM43lrBtCUBsFDw22XVjQcxe4QO/M+F7bOwNUJ7QmDPhrPBoUaRQucIcKQY6PLNT8so0fS7Kg9nx6X5ilDfRKKag20mXvSb79ITjd+rmCA7q6OD+U+o41Y5UQjhfq5yEt6IM2mVZtfsE49WkTNRjbi66FlyoqZPHRlrH1elQHZIZBaGQHsGQSDdS83jU3LmP1CSbRf/VhUs5YbGYsK+YR+BJ62fQh8DKzN59pAbRRgxcRTRi7WSyxE1pWGGWSuweJFew46lH8s+enQjpoG1ZKJfyoVAT0l0uHWsplbiJ7w=="
User-Agent: pherephone (go-fed/activity v1.0.0)
X-Forwarded-For: 127.0.0.1
X-Forwarded-Host: writefreely.xps
X-Forwarded-Server: writefreely.xps

body

{
  "@context": "https://www.w3.org/ns/activitystreams",
  "actor": "http://floorb.qwazix.com/nuerList",
  "object": "http://writefreely.xps/api/collections/qwazix",
  "to": "http://writefreely.xps/api/collections/qwazix",
  "type": "Follow"
}

which writefreely munches on and spits back like this (I don't know why)

{
  "@context": [
    "https://www.w3.org/ns/activitystreams"
  ],
  "actor": "http://floorb.qwazix.com/nuerList",
  "object": "http://writefreely.xps/api/collections/qwazix",
  "to": "http://writefreely.xps/api/collections/qwazix",
  "type": "Follow"
}

Mastodon follow

{
  "@context": "https://www.w3.org/ns/activitystreams",
  "id": "https://cybre.space/5d17c76b-d31f-4e13-8f23-479a71426135",
  "type": "Follow",
  "actor": "https://cybre.space/users/qwazix",
  "object": "https://floorb.qwazix.com/activityserve_test_actor_2"
}

Mastodon unfollow

{
  "@context": "https://www.w3.org/ns/activitystreams",
  "id": "https://mastodon.social/users/qwazix#follows/3183749/undo",
  "type": "Undo",
  "actor": "https://mastodon.social/users/qwazix",
  "object": {
    "id": "https://mastodon.social/9ac14b4d-5c46-4d58-835c-c09af5a9a430",
    "type": "Follow",
    "actor": "https://mastodon.social/users/qwazix",
    "object": "https://floorb.qwazix.com/myAwesomeList1"
  }
}

Webfinger response

{
    "subject": "acct:[email protected]",
    "aliases": [
        "https://example.com/qwazix",
        "https://example.com/qwazix"
    ],
    "links": [
        {
            "href": "https://example.com/",
            "type": "text/html",
            "rel": "https://webfinger.net/rel/profile-page"
        },
        {
            "href": "https://example.com/qwazix",
            "type": "application/activity+json",
            "rel": "self"
        }
    ]
}