Freebie Instagram Auto-Liking Script

Discussion in 'Instagram' started by ringtail, Oct 7, 2014.

  1. ringtail

    ringtail Registered Member

    Dec 29, 2013
    Likes Received:
    Hey Guys,

    I thought its about time I give something back to the community so here it goes. This is a Python script that I edited and added to after finding it on GitHub. I used to use this script to automate my liking activity back when I first got started out with IG almost 2 years ago. It is intended to be run on a single account with no proxy support (probably best for beginners wanting a little IG juice before jumping into bots). I don't use it much anymore due to a more robust bot I have but am sure someone will find it useful. So here's how to get started!

    1) Install Python on your computer (great news, Macs and Linux boxes are good to go! Windows users, hit some YouTube tuts and come right back)
    2) Save the code below somewhere on your computer and give it a name with a .py suffix. (e.g. << very important.
    3) Edit the code for you to use. I intentionally set it to be VERY safe. Input the tags you want to like in the TAGS variable, adjust the max_sec for upper threshold of liking pause, adjust the number under #TIME RANDOMIZER in the likeusers function for the lower threshold of the liking pause. Edit the max_count variable for the max numbers of photos you will like per tag. Use the URL at the top of the script to get your auth token; ensure you are not singed into any IG accounts, put that URL in your browser, log in and authorize the account you want to automate, grab the access_token string that is returned in the URL bar and place it in the auth_token variable below. Save the file.
    4) Open up a terminal, traverse to the directory where you stored your file and execute it! (for example, if you are on a mac or linux box and you saved it to your desktop your would issue the following commands in terminal:
    cd desktop
    python )
    5) You will see the text Starting Auto Liking Script in the terminal window followed by a URL and the number of seconds the script paused between likes. You can now sit back and enjoy, just don't let your computer turn off or the script will stop.:D

    Hope someone finds this useful! BHW FTW!

    import time, random, urllib, json, urllib2
    #Hashtags to like on
    TAGS = ["like4like", "20likes"]
    #Max number of likes per hashtag
    max_count = 20
    #Max seconds to wait between likes
    max_sec = 100
    #Use this url to get the auth_token
    #Input access_token string from URL into auth_token
    auth_token = ' PLACE ACCESS_TOKEN HERE '
    client_id = '1627c123e3fc481791e0d6be16ff57a0'
    user_agent = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7'
    headers = {'User-Agent': user_agent,
               "Content-type": "application/x-www-form-urlencoded"
    likedDict = {}
    print "Starting Auto Liking Script"
    def likePicture(pictureId):
        liked = 0
            urlLike = ""
            values = {'access_token': auth_token,
                      'client_id': client_id}
            newLike = urlLike % (pictureId)
            print newLike
            data = urllib.urlencode(values)
            req = urllib2.Request(newLike, data, headers)
            response = urllib2.urlopen(req)
            result =
            dataObj = json.loads(result)
            liked += 1
        except Exception, e:
            print e
        return liked
    def likeUsers(max_results, max_id, tag, c):
        global paginationId
        urlFindLike = "" % (
            tag, auth_token)
        urlLike = ""
        values = {'access_token': auth_token,
                  'client_id': client_id,
                  'max_id': max_id}
        f = urllib.urlopen(urlFindLike)
        dataObj = json.loads(
        numResults = len(dataObj['data'])
        pictureId = 0
        for likeObj in dataObj['data']:
            print ''
            pictureId = likeObj['id']
            paginationId = dataObj['pagination']['next_max_id']
            user = likeObj['user']
            userId = user['id']
                numLikes = likedDict[pictureId]
                numLikes = numLikes + 1
                likedDict[pictureId] = numLikes
                numLikes = 1
                likedDict[pictureId] = numLikes
                result = likePicture(pictureId)
                c = c + result
                seconds = max_sec
                #TIME RANDOMIZER
                seconds=random.randint(35, max_sec)
                print "Sleeping %s Seconds" % (seconds)
                if (c % 10 == 0):
                    print "Liked %s:  %s" % (tag, c)
                if (c == max_results):
            except Exception, e:
                print e
        if (c != max_results):
            likeUsers(max_results, paginationId, tag, c)
        return c
    for tag in TAGS:
        c = 0
        c = likeUsers(max_count, 0, tag, c)
        print "Liked: %s for tag %s" % (c, tag)
    for likes in likedDict:
        print "%s = %s" % (likes, likedDict[likes])
  2. ExecutiveDude

    ExecutiveDude Power Member

    Jul 21, 2014
    Likes Received:
    Great share buddy . Let me try it out
    If i face any issues will post back here
  3. laowai

    laowai Power Member

    Feb 27, 2011
    Likes Received:
    Have you run this script recently?

    There is hardcoded client id '1627c123e3fc481791e0d6be16ff57a0' so everyone running this same script would be consuming the total request limit, set by IG API, of the app that this id originally belongs to which would likely cause requests to fail at some point.

    You mentioned that you run this 2 years ago when the limits didn't exist yet as far as I know.
  4. ringtail

    ringtail Registered Member

    Dec 29, 2013
    Likes Received:
    Yes, I ran it before releasing it. The Instagram API works in the following manner. A client is assigned a client ID to authenticate and communicate with the IG API. Users of the client are assigned an access token which gives them their own individual 'request limit' when registered with that client. Therefore, each user with a unique access token will have their own clean 'request limit' to use.

    In other words, if your above architecture was correct, applications such as webstagram and iconosquare would cease to exist because after about the first minute of every hour, their request limit would be hit and for the other 59 minutes you wouldn't be able to do anything on their sites. Subsequently all bots using those sites or similar client/access token architecture would not exist either.
  5. chyldrenofthestars

    chyldrenofthestars Newbie

    Sep 8, 2015
    Likes Received:

    I attempted to use your script but keep getting an "HTTP Error 400: BAD REQUEST". I followed your directions and was able to get the auth_token and the script runs, but after each pause the script continuously has the HTTP Error 400: BAD REQUEST.

    Does this script no longer work, just wondering.

    Thank You!!!!