如何获取用于在Instagram中访问用户详细信息的'id' [英] How to get the 'id' for accessing user details in instagram

查看:482
本文介绍了如何获取用于在Instagram中访问用户详细信息的'id'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何获得id以通过instagram API的(Hashie::Mash)user(id)方法访问用户信息或通过(Hashie::Mash)location(id)访问他/她的位置?

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)?

我正在为项目使用Rails.

I am using rails for my project.

推荐答案

您可以搜索用户以获取其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.

这篇关于如何获取用于在Instagram中访问用户详细信息的'id'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆