1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Freebie Instagram Auto-Liking Script

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

  1. ringtail

    ringtail Registered Member

    Joined:
    Dec 29, 2013
    Messages:
    59
    Likes Received:
    20
    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. pythonliker.py) << 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 pythonliker.py )
    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!


    Code:
    
    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
    #   https://api.instagram.com/oauth/authorize/?client_id=1627c123e3fc481791e0d6be16ff57a0&redirect_uri=http://smallhours.fm&response_type=token&display=touch&scope=likes+relationships
    
    
    #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
        try:
            urlLike = "https://api.instagram.com/v1/media/%s/likes"
            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 = response.read()
            dataObj = json.loads(result)
            liked += 1
        except Exception, e:
            print e
        return liked
    
    
    
    
    def likeUsers(max_results, max_id, tag, c):
        global paginationId
        urlFindLike = "https://api.instagram.com/v1/tags/%s/media/recent?client_id=9e262d946e4f4d9987885588669e8b4f&access_token=%s" % (
            tag, auth_token)
    
    
        urlLike = "https://api.instagram.com/v1/media/%s/likes"
        values = {'access_token': auth_token,
                  'client_id': client_id,
                  'max_id': max_id}
    
    
        f = urllib.urlopen(urlFindLike)
        dataObj = json.loads(f.read())
        f.close()
        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']
            try:
                numLikes = likedDict[pictureId]
                numLikes = numLikes + 1
                likedDict[pictureId] = numLikes
            except:
                numLikes = 1
                likedDict[pictureId] = numLikes
    
    
            try:
                result = likePicture(pictureId)
                c = c + result
                seconds = max_sec
                #TIME RANDOMIZER
                seconds=random.randint(35, max_sec)
                print "Sleeping %s Seconds" % (seconds)
                time.sleep(seconds)
                if (c % 10 == 0):
                    print "Liked %s:  %s" % (tag, c)
                if (c == max_results):
                    break
            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 Regular Member

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

    laowai Power Member

    Joined:
    Feb 27, 2011
    Messages:
    522
    Likes Received:
    184
    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

    Joined:
    Dec 29, 2013
    Messages:
    59
    Likes Received:
    20
    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

    Joined:
    Sep 8, 2015
    Messages:
    1
    Likes Received:
    0
    Hi,

    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!!!!