且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2023-12-04 09:17:16

您可以搜索用户以获取其ID,例如:

You can search for a user to get his/her id, e.g:

shaynesids = Instagram.user_search("Shayne Sweeney")

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

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.