Ghost / Ayrshare Integration (template)

TL;DR: Automatically share Ghost posts to social media channels for free.

I discovered a neat service called Ayrshare yesterday that is a developer-first social media scheduling tool. Meaning they handle all the complexities of the various social platform APIs to allow developers to send out posts over a single API. So to try it out I wrote a basic API to connect my Ghost site to their API.

Something I missed from WordPress was the ability to auto-share my posts to social media through a plugin from Automatic called Publicize. So this service caught my eye.

The script linked to below will create an API that you can have Ghost send a webhook request to every time you publish a new post. If you’ve never created an integration in Ghost before it’s simple, just go into Settings > Integrations, create a new integration, and in that integration create a webhook that points to your API’s endpoint.

Below you’ll find a GitHub gist with a small snippet that you can paste into a CloudFlare worker (very generous free plan). With some modifications, you could probably use any serverless function service. You will want to create two environmental variables on your Worker (easy to do in the CloudFlare dashboard) for your Ayrshare API key and a very basic authentication code that gets passed in the URL to keep out crawlers and the like. It’s all in the gist’s comments if you get stuck.

I’m considering upgrading to a paid Ayrshare plan, but I haven’t yet and you don’t have to either. Currently I’m running the whole integration on CloudFlare and Ayrshare free tiers. You get 30 Ayrshare requests for free per month which seems perfect for most blogs and small publications.

This should be mostly copy and paste but if there are any questions feel free to @ me below and I’ll try to respond.