How to Post Articles to Dev.to Using iOS Shortcuts

How to Post Articles to Dev.to Using iOS Shortcuts


This guide will walk you through the process of posting articles to Dev.to using iOS Shortcuts, without needing any additional tools like cURL or Postman.



Prerequisites

Before you start, make sure you have the following:

  1. Dev.to API Key

  2. Shortcuts App

    • Ensure the Shortcuts app is installed on your iPhone.



Step 1: Create a Shortcut

  1. Open the Shortcuts app and tap the “+” in the top right corner to create a new shortcut.
  2. Tap Add Action, search for “Text” and select it.
  3. In the text box, input the following JSON template (you can adjust the content as needed):

{
“article”: {
“title”: “Automated API Post Test”,
“published”: true,
“body_markdown”: “This is an article posted through iOS Shortcuts.nn## Featuresn- Supports Markdown.n- Automated posting.”,
“tags”: [“API”, “Automation”, “iOS”]
}
}



Step 2: Add HTTP Request

  1. Tap Add Action, search for “Get Contents of URL” and select it.
  2. In the URL field, enter the Dev.to API URL:

https://dev.to/api/articles

  1. Set the method to POST.
  2. Tap Show More and configure the following:
  3. Headers:

    • Tap Add Field, and enter:
    • Key: Content-Type, Value: application/json
    • Key: api-key, Value: (paste your Dev.to API key here)
  4. Request Body:

    • Select JSON.
    • Tap Add Field and set the text action you created earlier as the JSON data source.



Step 3: Add Result Notification (Optional)

  1. Tap Add Action, search for “Show Notification” and select it.
  2. Set the notification content to:

Article successfully posted to Dev.to!



Step 4: Save and Test

  1. Tap the shortcut’s name at the top and give it an easily recognizable name, such as “Post to Dev.to”.
  2. Save the shortcut and tap to run the test:
  3. If everything is set up correctly, the article will be posted to your Dev.to account.



Optional Features



Dynamic Title and Content Input

  • Add the “Ask Each Time” action to prompt the user for input like title, content, or tags.
  • Example:
  • In the Text action, remove the fixed title or content and add a variable.
  • Input the article title and body each time you run the shortcut.



Debugging Errors

  • If the article fails to post, add a “Show Result” action to display the HTTP response and check for errors.



Scheduled Posting

  • Use Automations within the Shortcuts app to set up a scheduled task that runs the shortcut automatically at specified times.



Conclusion

With the steps above, you can easily post articles to Dev.to directly from iOS using Shortcuts. If you need further customization, like batch posting or scheduling, you can refine the shortcut to fit your needs.

Feel free to leave a comment if you have any questions or need further assistance!



Source link
lol

By stp2y

Leave a Reply

Your email address will not be published. Required fields are marked *

No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.