Apple Shortcuts for posting to WordPress via the REST API and XML-RPC MetaWeblog API

Jim Willis asks,

it seems that the iOS WordPress app’s “Post to WordPress” is no longer working, so I’d like to fallback to the rpc endpoint. Any chance you could share a link to your shortcut so I could take a look what you did here?

Certainly! I’m replying as a post because I think it might help other people, too.

I made two versions, one using the REST API and one using the XML-RPC MetaWeblog API.

REST API

Docs for making posts with the WordPress REST API: https://developer.wordpress.org/rest-api/reference/posts/

Shortcut link: https://www.icloud.com/shortcuts/182b3a80dff54b27a4d7464cfc139b81

How it works:

Takes input for a title and content. These are turned into variables.

If you don’t want a title, you can change this, but make sure your theme supports not having titles.

When you first set up the shortcut, add your username and an Application password in the format: username:password in the provided text block. This gets base64 encoded and passed to the cURL request as a basic authorization header.

The Get Content of URL block makes a POST to /wp-json/wp/v2/posts (Update your domain here!)

The variables for title and content get passed into the appropriate key in the JSON request body. I included title, content, and status, as those are the three that are needed. You can include tags, categories, slug, excerpt, etc. Anything in the docs. All pretty simple, you just need to make more variables and pass them along in the JSON body.

I included a block that gets the link back from the successful POST and prompts you to view it. Feel free to remove it if you don’t like it.

XML-RPC MetaWeblog API

Docs for the WordPress XML-RPC MetaWeblog API: https://codex.wordpress.org/XML-RPC_MetaWeblog_API

Shortcut link: https://www.icloud.com/shortcuts/4a199bb32d654721a4aac9a773c664f1

How it works:

Takes input for a title and content. These are turned into variables.

If you don’t want a title, you can change this, but make sure your theme supports not having titles.

When you first set up the shortcut, add your username and an Application password in the provided text blocks. These get turned into variables and passed to the XML that we send to xmlrpc.php.

The XML is stored as a text block, which is then turned into a variable and passed as a file along with the request.

I only included the username, password, post title, and post content, but you can add whatever is supported by the API. You just need more variables and more members of the struct.

The Get Contents of URL block makes a POST to the /xmlrpc.php endpoint (change the value for your domain!) with Content-Type of text/xml and the request body as a file.

If you run into any issues, let me know! I’m happy to help.