Instagram how to get my user id from username?

前端 未结 24 1066
傲寒
傲寒 2020-11-30 17:14

I\'m in the process of embedding my image feed in my website using JSON, the URL needs my user id so I can retrieve this feed.

So, where can I find/get my user id?

24条回答
  •  时光取名叫无心
    2020-11-30 17:34

    Although it's not listed on the API doc page anymore, I found a thread that mentions that you can use self in place of user-id for the users/{user-id} endpoint and it'll return the currently authenticated user's info.

    So, users/self is the same as an explicit call to users/{some-user-id} and contains the user's id as part of the payload. Once you're authenticated, just make a call to users/self and the result will include the currently authenticated user's id, like so:

    {
        "data": {
            "id": "1574083",
            "username": "snoopdogg",
            "full_name": "Snoop Dogg",
            "profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_1574083_75sq_1295469061.jpg",
            "bio": "This is my bio",
            "website": "http://snoopdogg.com",
            "counts": {
                "media": 1320,
                "follows": 420,
                "followed_by": 3410
            }
    }
    

提交回复
热议问题