【问题标题】:How to get the 'id' for accessing user details in instagram如何获取“id”以访问 instagram 中的用户详细信息
【发布时间】:2012-01-10 08:37:24
【问题描述】:

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

我正在为我的项目使用 Rails。

【问题讨论】:

  • 您能否添加更多有关您如何访问 Instagram API 的信息并发布相关代码?你在使用 ActiveResource 吗?
  • 我已经安装了 instagram gem。在 yard doc -> [ ruby​​doc.info/github/Instagram/instagram-ruby-gem/master/Instagram/Client/Locations#location_recent_media-instance_method ] 中,Instagram.location(id) 提供有关给定 instagram 位置的信息.我如何获得这个'id'?

标签: ruby-on-rails ruby instagram


【解决方案1】:

您可以搜索用户以获取他/她的id,例如:

shaynesids = Instagram.user_search("Shayne Sweeney")

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

myuser = Instagram.user(shaynesids.first)

注意:在这里我假设搜索将返回至少一个结果,您需要在代码中小心处理错误,因为它可能返回一个空数组。

【讨论】:

    猜你喜欢
    • 2014-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-23
    • 2013-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多