In my spare time I'm drawing cartoons. After finishing one, I want to publish them on several social media platforms:
On every platform I have a personal profile where I publish everything and a profile for cartoons related to developer topics.
My workflow currently is:
Wow! Many steps that has to be done manually before I can annoy everyone with my bad drawings!
I was asking myself if this can't be automated. Of course this is possible to some degree. I do not know if this can be done more efficient. Let me know!
If this than that is a service where you can define workflows based upon start actions. E.g. "if I receive an email from xxx then send one to yyyy" and stuff like that.
It also provides Twitter, Instagram and Facebook integration. And it is free!
Accounts
IFTTT
allows only one Twitter/Instagram/Facebook connection per IFTTT account. As we want to control two social media profiles per platform, we need two IFTTT
accounts. In this blog post I use the term private IFTTT account
for that one that is connected to my private social media profiles. Accordingly I call my account that is linked to my KackDev
social media profiles KackDev IFTTT account
.
I use Planoly
for this task. But it is not required. Planoly
allows me in the free tier to maintain one Instagram account and to create many hashtag sets. The later is the reason why I fall back on a third party tool. I do not want to search the hashtags manually all the time I make a post.
Now I need a Instagram <-> Twitter
integration in my KackDev IFTTT account. Luckily someone has published such an applet at IFTTT
.
If you are new to IFTTT, your start screen will look like this:
Klick onto the magnifying glass at the top and type in "twitter". You will see many results.
We are interested in the second applet "Tweet your Instagrams as native photos on Twitter". Click onto it. Press the big "Connect" Toggle. Now IFTTT
will redirect you to Instagram which will ask you to authorize IFTTT
. In my case I link my KackDev Instagram account with my KackDev IFTTT account. Now You will be redirected to IFTTT which then redirects you to Twitter. Here I link my KackDev Twitter account.
If you see following screen, everything works as expected:
Well, nothing more has to be done. I have activated the applet, linked both social media accounts to my KackDev IFTTT account.
This one is easy. I go to my KackDev IFTTT account and search for "Facebook":
Click onto the applet "Post your Instagram photos to a Facebook page". Again IFTTT asks you to authenticate - this time against Facebook. In the next step you select the Facebook page.
What you have until now:
Following steps are missing, yet:
This is a bit more tricky. Twitter does not allow to define an applet that can retweet tweets of specific user. This can be solved by several ways. I prefer to write a small microservice that is triggered by IFTTT. You have to create or reuse existing tokens of your twitter developer account.
const Twitter = require("twitter-lite");
const express = require("express");
require("./envvars");
function retweet(id, TWTR_CKEY, TWTR_CSECRET, TWTR_ATOKEN, TWTR_ASECRET) {
const client = new Twitter({
subdomain: "api",
consumer_key: TWTR_CKEY,
consumer_secret: TWTR_CSECRET,
access_token_key: TWTR_ATOKEN,
access_token_secret: TWTR_ASECRET
});
return client.post("statuses/retweet/" + id);
}
var app = express();
app.get("/", async (req, res) => {
console.log("new request");
const link = req.query.link;
console.log("link: " + link);
const id = link.match(/.*\/([0-9]{6,})/)[1];
console.log("id: " + id);
const secret = req.query.secret.trim();
if (process.env.SECRET.indexOf(secret) <= -1) {
console.log("wrong secret");
res.sendStatus(401);
return;
}
try {
const result = await retweet(id, process.env.TWTR_CKEY, process.env.TWTR_CSECRET, process.env.TWTR_ATOKEN, process.env.TWTR_ASECRET);
res.sendStatus(200);
} catch(e) {
console.log(JSON.stringify(e))
res.sendStatus(500);
}
});
app.listen(44320, () => console.log("listening on port 44320"));
The service is quite simple. It just accepts a GET
request, containing the Tweeturl and a secret key as query parameter. From the URL the tweet ID is extracted and used to send the retweet request. Log in into your private IFTTT account, go to platform.ifttt.com and find the button to create a new applet:
Note: Users in the free tier on IFTTT can create applets for free but they can not publish them to other users.
Create an applet with Twitter as Trigger and a Webhook as Action:
As value
for the URL
field in the webhook, you choose something like that:
http://link-to-your-service/?link={{LinkToTweet}}&secret=a_secret
After saving it, you can view it in your private IFTTT account by clicking this icon:
If you click onto it, you are redirected to IFTTT and you can connect that applet to your account. During this process you will have to connect your private twitter profile with your IFTTT account if you haven't done that yet.
Result:
From now on every tweet from @KackDev is retweeted to my private twitter account.
Well, due to breaking changes in the Facebook & Instagram API, no one is able to post to private FB and Instagram accounts anymore. That means I have to post it to my private Instagram account manually. Also the post on the Facebook page must be reposted manually.
If you have an idea how this can be solved, let me know :-)
I showed you how I utilize IFTTT
to spread a post at my business Instagram account to other platforms. This reduces the effort for maintaining social media accounts. Also you may got an idea what is possible with IFTTT
.
As I am not a native English speaker, it is very likely that you will find an error. In this case, feel free to create a pull request here: https://github.com/gabbersepp/dev.to-posts . Also please open a PR for all other kind of errors.
Do not worry about merge conflicts. I will resolve them on my own.
Special thanks to our guest blogger Josef Biehler, a Front-end Engineer of Finaps for his contribution to the Ronald James Blog this week.
Visit the original link for this blog here.
We are a leading niche digital & tech recruitment specialist for the North East of England. We Specialise in the acquisition of high-performing technology talent across a variety of IT sectors including Digital & Technology Software Development.
Our ultimate goal is to make a positive impact on every client and candidate we serve - from the initial call and introduction, right up to the final delivery, we want our clients and candidates to feel they have had a beneficial and productive experience.
If you’re looking to start your journey in sourcing talent or find your dream job, you’ll need a passionate, motivated team of experts to guide you. Check out our Jobs page for open vacancies. If interested, contact us or call 0191 620 0123 for a quick chat with our team.
Follow us on our blog, Facebook, LinkedIn, Twitter or Instagram to follow industry news, events, success stories and new blogs releases.
Back to Blog