Creating a PHP Instagram bot

gman777

Power Member
Joined
Apr 7, 2016
Messages
715
Reaction score
676
Hey, guys. I was thinking of creating a bot for Instagram using PHP. Is there any limitation to why I can't do it? I mean Massplanner and Follow Liker are made using a desktop language.

And looking on the web, I can't see people sharing any reliable bot like instabot py for example?

Also, how long does it take to create a good bot like Massplanner? Some people said 3 to 6 months. Time investment is not a problem.
 
It takes as long as much experience you have.
 
First I have to admit, I haven't really builld bots with php, just some lowlevel scrapers, but some things I learned with multiple projects / apps I'd like to share.
Also I'm not sure about how experienced you're with coding, so I might tell you nothing new but here we go.

As a starting point have a look at some git repos on github for bot examples here

With a bot for mid to larger scale you like to have a look into pthreads here, as you would like to run your scripts in multiple instances / threads. Quick and dirty tut here.

So to have a good performance you would need to seperate your frontend to a regular webserver enviroment and your actual botting scripts as cli scripts.
pthreads afaik is only available for cli at the moment. You probably want to implement some kind of spooler / queue for those scripts

I'm not sure if you would use the official API of instagram, that may depend on your bot and what your planing to do.
So afaik there might be some problems to login on instagram with curl or something from a php script.
Propably you would need to make use of some headless browser. There are multiple posts to that on sites like stackoverflow, I link you a few here, and here.

Depending on the enviroment and settings you gonna run your bot, resources could become a bottle neck. So you could easily run into memory limits.
There are many docs on how to prevent that, to get you started read here, here, here.

How long would it take? Depends on your coding experience, planing and feature set. The basics like frontend, queue, basic bot scripts and stuff like could be easily done in a week or two.
I think the tricky part comes when you start building the actions the bot should perform on instagram. As I'm not into instagramm I got no clue what features you want or need.

Hope I could help you out a bit.
 
can be done but your need java added can not be done with php only Impossable

curl to slow ....
 
Forget about it, it is better to use C# or java to make an instagram bot. If you would like to automate a single account, then php will be fine.
 
can be done but your need java added can not be done with php only Impossable

curl to slow ....

that's quite wrong.

CURL has some problems with DNS look-ups. Try using IP address instead of domain name.
That maybe not an option, but

If curl is slow, it is generally not the PHP code, it's almost always network related.

also

The curl functions in php directly use the curl command line tool under *nix systems.

Therefore it really only depends on the network speed since in general curl itself is much faster than a webbrowser since it (by default) does not load any additional data like included pictures, stylesheets etc. of a website.

It might be possible that you are not aware, that the network performance of the server on which you were testing your php script is way worse than on your local computer where you were testing with the browser. Therefore both measurements are not really comparable.

Anyway you would like to mimic a real user, by using some headless browser. So you need to add in some different tools like node or stuff.

I admit php would suck at different parts more than other languages. Depending on the feature set somethings would be doable.
 
Thread moved to the proper place.

Short answer - yes, but you'll need to overcome hurdles that you wouldn't in languages that have native threaded/events. You can have both threads and events on PHP as well via extension but you're treading on low traffic paths - when you get stuck, good luck.

A way to overcome that problem is by using a microservice-based architecture. Short-lived scripts have the advantage of simplicity, no worries about memory leaks (which you'll get in long running scripts) and ease of development. The cost you pay is the increase of complexity in the architecture.
 
And also, everything would run on your server and you'd pay for the costs. If the app is desktop the end user pays for the bandwidth and whatnot. Just imagine having 1000 users at the same
 
If you are going to choose a programming languages,
I suggest better assumed can be support to more customers in future :)
 
Back
Top