Posts without posting: building a social media sharing relay with F♯ and Azure Functions, part 4

In the first three parts of the series, I set up an Azure Functions endpoint to accept a URL and a comment and share it across various social media sources. The last step of making this a proper workflow is to build the iOS shortcut.

The last two parts of this series were very long and tech heavy. This part is mercifully shorter and actually quite easy. The goal here is to create a shortcut in iOS to extract the URL and page title from a website I am visiting, prompt me for a comment, and then hit the API endpoint previously set up with an authentication key. This can be done with the built-in iOS Shortcuts app that ships with all current versions of iOS.

Posts without posting, a series

  1. Architecting a relay
  2. Writing the code
  3. Configuring Azure Functions with Terraform
  4. Setting up an iOS Shortcut

This is a very simple seven step process. In the iOS Shortcuts app, let’s create a shortcut called “Post Link”. The steps are as follows:

  1. Get Any input from Share Sheet (Sharing -> System -> Share)
  2. Ask for Text with Comment (Scripting -> Notification -> Ask for Input)
  3. Set variable Tweet to Provided Input (Scripting -> Variables -> Set Variable)
  4. Get Page URL from Shortcut Input (Web -> Safari -> Get Details of Safari Web Page)
  5. Get Name from Shortcut Input (Web -> Safari -> Get Details of Safari Web Page)
  6. Enter URL of endpoint (Web -> URLs -> URL)
  7. Get Contents of URL (Web -> Web Requests -> Get Contents of URL)
  8. Set Method to POST
  9. Add a header with key set to x-functions-key and text set to your function key as found in the Azure Function you just set up

That’s it! Here are some images of how mine looks. To use this, whenever I am viewing a website, I can simply open the share tray and click “Post Link.”

First page of the shortcut described above as shown in the iOS app Second page of the shortcut described above as shown in the iOS app

Posted: 08.01.2023

Built: 14.10.2024

Updated: 24.04.2023

Hash: 765e2d9

Words: 319

Estimated Reading Time: 2 minutes