C
C
cehka2019-05-18 22:30:33
API
cehka, 2019-05-18 22:30:33

How to get the latest likes of a post on Instagram?

You need to get the last 5-10 people who liked the post on Instagram.
If not, then the last 5-10 followers.
How to do it? The API does not respond to them at all (I'm a registered developer)
Is it possible to do this somehow without the API? If so, how?
Thank you very much in advance for your reply.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
cehka, 2019-05-30
@cehka

The answer was on the surface.
unoffical instagram api wrapper
Code itself:

def get_media_likers(API, mediaID):
    retUsers = []
    while True:

        API.getMediaLikers(mediaID)

        usersJson = API.LastJson
        for user in usersJson['users']:
            retUsers.append(UserProfile(user['pk'], user['username']))
        else:
            break
    return retUsers

Where API is instagram authorization (see link)
User Profile:
class UserProfile:
    def __init__(self, id, username):
        self.id = id
        self.username = username

I get the mediaID like this:
parse = urlparse(url)
    path = parse[2]
    apiUrl = "https://api.instagram.com/oembed/?url=http://instagram.com/{}".format(path)
    r = requests.get(apiUrl)
    mediaID = r.json()['media_id']

And in addition, here's how I check if a person has liked a post.
def is_instagram_like(username, url):
    if url[-1] != "/":
        url = url + "/"
    parse = urlparse(url)
    path = parse[2]
    apiUrl = "https://api.instagram.com/oembed/?url=http://instagram.com/{}".format(path)
    r = requests.get(apiUrl)
    mediaID = r.json()['media_id']
    likers = get_media_likers(API, mediaID)
    for liker in likers:
        if liker.username == username:
            return True
    return False

P
Puma Thailand, 2019-05-19
@opium

Well, open the site and look at the request

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question