Some would believe this shouldn't be possible, that Meta has enough standards in-place to prevent automation on their platforms... but hey: no, it's not the case. A year ago I developed a prototype that allowed me to perform the two following tasks:
- Auto post images and reels;
- Auto comment on other people's posts;
The code was a mess, and not really my most proud moment, but I did manage to automate the creation of posts when new job opportunities were made available on my recruitment platform, both in the format of singular image posts or reels.
How did I do it?
The first step was to make some analysis of what was going on in the network tab of the developer tools on my browser when I'd post a story or a reel. So, I noticed the invocation of a few endpoints: one where the image would get uploaded and another that would follow with the "id" of the upload, and the information of the post, like the caption, the location or other properties that you can set on the UI.
Assuming now that we are only posting singular images, let's take a look at the requests we will have to make:
POST /rupload_igphoto/fb_uploader_172980285889
with the image as payload -> the 172980285889 represents the current time.
POST /api/v1/media/configure
with the caption, and other options in the payload;
These two requests do the trick to programatically post on Instagram. Though, that's not it. You'll require the right headers. These include your session, the latest CSRF token and a few other headers that represent the app versions of instagram, like the ASBD-ID
or the Instagram-AJAX
.
Great! You can programatically post to instagram, but now you might wonder: how to actually automate the posting? Well, depends what you want to achieve. If you have a collection of posts prepared, but you just want to take out the effort of going through the process of instagram, then I'd suggest you to create a folder with those posts, create an excel sheet where you can have the caption and the day it is supposed to be posted, and programatically go through these lists, pick the image, upload it to the first endpoint, get the caption and upload it to the second endpoint.
Alternatively, you can do it like I did it for Cosmo Crafter: I created a few HTML templates linked those templates to the data on the database that I wanted to collect to use on the posts, created a service to programmatically take the screenshots, and save the image and finally I plugged that with my Instagram "integration" class to post the last generated asset.
I'll be happy to share some more code if you'd like to bring automated posts to your account too.
One thing to keep in mind:
Don't go "nuclear" on the auto-posting nor use regular, recognisable patterns, this because Instagram has developed algorithms that help them detect automation like this. But, with the right mindset, all the challenges are smoothly faced: on this case, to prevent the notion of automation, we have put a sleep in place. This means that a post that is automated to be posted at 9:00 might take a few more minutes to actually be processed. We made our script stop between 5 and 30 minutes, randomly. And we don’t execute the HTTP POSTs in sequence, we always give it a couple of seconds in-between operations.
Keep those in-mind for a successful integration and not a block 😃