Instagram API -Get the userId

拥有回忆 提交于 2019-11-30 10:15:52
Claus Wolf

The mentioned website otzberg.net/iguserid is my personal site and I shut it down, based on the API announcement, which was correctly mentioned by Daniel Storm. The type of tool would never be approved by Instagram. However there are a few easy steps to get your Instagram User-ID, use Google Chrome and the Developer Tools (F12 or ⌥ + ⌘ + i)

In the console view of the profile page (e.g. https://www.instagram.com/lufthansa/) type:

    window._sharedData.entry_data.ProfilePage[0].user.id

Here a screenshot:

Definitely not the most elegant way, but without involving a running browser or an approved application, is to use the (undocumented?) search API:

https://www.instagram.com/web/search/topsearch/?context=user&count=0&query={username}

This returns matching users (as count is set to 0 it should not return more than one user).

After validating the results (checking if user includes one item), you can get the userid e.g. in javascript with

response.users[0].user.pk

where response is an object with the parsed response.

From Instagram:

On November 17, 2015, we announced a new permissions review process for new and existing apps on the Instagram for Developers blog. All existing apps have until June 1, 2016 to submit for review before being transitioned to sandbox mode. Please submit for review only if you are in compliance with one of our approved use cases.

You need to get your API usage approved.

Check Instagram's Platform Policy for use cases that are not allowed.

When you generate the access token.. there will be id in the json response

{"access_token": "", "user": {"username": "abcdef", "bio": "", "website": "", "profile_picture":", "full_name": "ABCEDEFE", "id": "000000000"}}

We can get userid by using this link. https://api.instagram.com/v1/users/self/?access_token=ACCESS-TOKEN

You can use this website - http://www.instaid.co.uk

Or you can do the following replacing {username} with your Instagram username

https://www.instagram.com/{username}/?__a=1

Or you can login to your Instagram account and use google dev tools and look at the cookies that have been stored. 'ds_user_id' is your user ID

I'm currently using https://codeofaninja.com/tools/find-instagram-user-id for that.

If you would like to use it as an api, you can use https://codeofaninja.com/tools/find-instagram-id-answer.php?instagram_username={username} and then parse the html response to get the user id

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!