简体   繁体   English

如何获取用于在Instagram中访问用户详细信息的'id'

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

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) ? 我如何获得id通过访问用户信息(Hashie::Mash)user(id)的Instagram的API的方法或通过访问他/她的位置(Hashie::Mash)location(id)

I am using rails for my project. 我正在为我的项目使用rails。

You can search for a user to get his/her id, eg: 您可以搜索用户以获取其ID,例如:

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: 这将为您提供与Shayne Sweeny匹配的用户数组上的所有id(希望只有一个),然后可以将其与user(id)一起使用,如下所示:

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. 注意:在这里,我假设搜索将至少返回一个结果,因此您在代码中要小心以解决错误,因为它可能返回空数组。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM