I love automating things. For a few years now I’ve configured my site using Jetpack’s Publicize module in conjunction with Buffer to automatically post new content to my social networks. However, there’s a couple of limitations with that approach:
- Publicize seemingly won’t let you use the post’s short URL,
- You have little control over when these posts go out on social media.
With my new found love of Zapier, I sought to rectify both of these issues.
First up: getting a YOURLS short URL for a post in Zapier. You can do this using the relatively new Code by Zapier app. This app allows you to run Python or JS to perform calculations, or modify or retrieve data.
I sought to leverage YOURLS’ API, whereby you can make HTTP requests to your YOURLS installation to get short URLs for any URL you provide.
My general process is to check an RSS feed for new entries (I didn’t feel comfortable providing a username and password to Zapier for my WordPress install in order to the use the WordPress app) and then to take the item URL from the RSS feed and send it to YOURLS to give me a short URL back (if a short URL exists it simply returns it: otherwise it creates one and returns it).
Item 1 in my zap is the RSS feed check. Item 2 is the Python code. Here’s what the code generally looks like where
article_url is an input created from the item link in Step 1:
When you run that, you should now have a short URL available to you for use in subsequent steps in your zap.
I then used this in conjunction with the Delay app to create new social posts on a set schedule using my short URL from YOURLS.
Seriously, I can’t get enough of Zapier right now…