Posting API

Micropub is a W3C recommendation for posting to your web site. It started life in the IndieWeb community and is now supported in several platforms.

Sending a new post to Micro.blog often looks as simple as this (where 123456789 is an app token):

POST /micropub
Authorization: Bearer 123456789

h=entry&content=Hello%20world.

To upload a photo to a Micro.blog-hosted blog, first query Micropub to get the media endpoint:

GET /micropub?q=config
Authorization: Bearer 123456789

This will return a response like:

{
  "media-endpoint": "https://micro.blog/micropub/media"
}

The media endpoint accepts a multipart/form-data upload with a file part containing the JPEG image data. Micro.blog will send back an HTTP 202 response while the image is being copied to the published site. It may take a few seconds for it to be available at the URL in the response:

HTTP/1.1 202 Accepted
Location: https://username.micro.blog/uploads/123.jpg

Now that you have the URL for the uploaded photo, you can add a photoparameter to a new post. To set alt text for the photo, also include an mp-photo-alt parameter.

POST /micropub
Authorization: Bearer 123456789

h=entry&content=Hello%20world.&photo=https://...&mp-photo-alt=Description%20here.

When creating a new post, the Micropub API also accepts a “name” parameter to give the post a title:

POST /micropub
Authorization: Bearer 123456789

h=entry&name=Hello&content=This%20post%20is%20longer.

To create a draft post, add the parameter “post-status” with the value “draft”. Micro.blog will return the final published URL for the post, even though it doesn’t exist yet, and in the JSON body of the response it will include a preview URL. You can direct users to this URL to preview the post on the web, where they can choose to publish it.

{
  "url": "https://username.micro.blog/hello.html",
  "preview": "https://micro.blog/account/posts/123/preview/456"
}

To retrieve a list of recent posts, the Micropub API supports /micropub?q=source. This is documented on the IndieWeb wiki. Micro.blog also allows editing an existing post or deleting a post as described in the Micropub spec.

Micro.blog supports Micropub on both the server and from the Micro.blog iOS app:

  • For posting from a third-party client to a Micro.blog-hosted microblogs, you can use IndieAuth or generate an app token under Account → “App tokens”. If you use a token, set it the Authorization: Bearer header.
  • For posting from the Micro.blog iOS and macOS apps to any Micropub server, under Settings → “When writing a new post” choose “WordPress or compatible weblog”. Enter your web site domain name and Micro.blog will look for an authorization endpoint to complete the setup.

Note: Micro.blog for iOS and macOS will always default to WordPress posting if your web site supports it, so that it can set a default category and post format.

For users who have multiple microblogs configured, /micropub?q=config will return of the list of sites. You can post to a specific microblog by passing an mp-destination parameter of the URL (uid from the configured list).

Need a way to test with multiple blogs? Every account can create a free test blog on the web under Design → Edit Custom Themes → New Test Blog.

The XML-RPC support allows you to post to a Micro.blog-hosted microblog and from the iOS app to WordPress, MovableType, and other compatible blogging platforms. For details see the overview help page and Micro.blog-specific XML-RPC API.

I am trying this out (as I was trying to write a Shortcut), but to test

curl https://example.com/micropub -d h=entry -d “content=Hello World” -H “Authorization: Bearer XXXXXXX”

Using my Micro.blog URL and token – for some reason it is sending me a “Not Found” reply.

Help.

If it is an iOS Shortcut I had one working before I ditched twitter and could probably help.

And if you are pointing it at your landing page, point it here instead: https://micro.blog/micropub

can you post the content of Get contents of URL (I presume URL is “https://example.com/micropub”, right?)? TIA

Yeah, I just need to decrypt what I did (I made it all complicated for parsing my Twitter threads).

Ok. looking forward to this. :slight_smile:

I can give a better look in the morning (when I am less beered and have a fresh dose of Adderall) but this looks relevant

Update: forgot about the innards and if it makes sense I may share a link to the shortcut for you to pick apart (it looks like I basically got all my data into variables and sent it here).

Another update: this looks like the shortcut I fed stuff to in order to do the actual posting. Untouched other than redacting the bearer stuff

Post to Micro.blog

1 Like

Thanks thanks

1 Like