【问题标题】:How to get 'id' parameter from the instagram api?如何从 instagram api 获取“id”参数?
【发布时间】:2012-01-10 10:44:11
【问题描述】:

有人能告诉我“如何获取”或“什么是”在 yard 文档 http://rubydoc.info/github/Instagram/instagram-ruby-gem 中给出的 ruby​​ instagram api 方法 location(id), location_recent_media(id,options{}), media_item(id), media_likes(id) 等中使用的 'id' 参数吗?我正在使用 rails 并且 api 是使用 gem 安装的。

【问题讨论】:

标签: ruby-on-rails ruby instagram


【解决方案1】:

您可以在此处https://github.com/Instagram/instagram-ruby-gem 中查看如何使用 API 的示例,查看代码我会说 id 取决于您查询的内容,如果您使用 location(id) 它会是位置的ID。现在,要从“真实世界”位置到该 id,我相信您可以使用 location_search(longitude, latitude),这将为您提供一个包含所有靠近该坐标的位置的数组,例如(来自代码文档):

Instagram.location_search("37.7808851", "-122.3948632")

这将为您提供一个包含 37.7808851、-122.3948632(164 S Park, SF, CA USA)周围位置的数组。

然后您可以使用带有 location(id) 的 id 数组,例如:

mylocations = Instagram.location_search("37.7808851", "-122.3948632")
Instagram.location(mylocations.first)

希望对你有帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-07
    相关资源
    最近更新 更多