How to get the 'id' for accessing user details in instagram
-
25-10-2019 - |
Question
How do i get the id
for accessing user info by (Hashie::Mash)user(id)
method of the instagram API or accessing his/her location by (Hashie::Mash)location(id)
?
I am using rails for my project.
Solution
You can search for a user to get his/her id, e.g:
shaynesids = Instagram.user_search("Shayne Sweeney")
That will give you all the ids on an array of user matching Shayne Sweeny (hopefully just one), then you can use it with user(id), like this:
myuser = Instagram.user(shaynesids.first)
Note: In here I'm assuming that the search it's gonna return at least one result, you will need to be careful in your code to account for errors, because it could return an empty array.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow