How to get the 'id' for accessing user details in instagram

倖福魔咒の 提交于 2019-12-13 03:20:59

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/8800459/how-to-get-the-id-for-accessing-user-details-in-instagram

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