Instagram gem API 示例——使用特定选项
我目前正在学习如何使用 Instagram 的 API,并一直在尝试 github 上提供的示例: https ://github.com/Instagram/instagram-ruby-gem
我克隆了他们的 sinatra 应用程序,它运行良好。但是,我希望能够使用提供的每个选项,例如用户搜索。
我工作的唯一照片提要是 user_recent_media(如下所示)和 media_popular。我通过简单地交换这两种方法来做到这一点。
Instagram 的 API 在其示例中展示了一个简单的 put 方法。我究竟如何才能让它发挥作用,以便我可以使用他们的所有选项,例如搜索、location_recent_media、follows 等?该示例中的哪些代码需要更改?
# Search for users on instagram, by name or username
puts Instagram.user_search("shayne sweeney")
# Get a list of media close to a given latitude and longitude
puts Instagram.media_search("37.7808851,-122.3948632")
get "/feed" do
client = Instagram.client(:access_token => session[:access_token])
user = client.user
html = "<h1>#{user.username}'s recent photos</h1>"
for media_item in client.user_recent_media
html << "<img src='#{media_item.images.thumbnail.url}'>"
end
html
end
I'm currently learning how to use Instagram's API and have been playing around with the example provided on github: https://github.com/Instagram/instagram-ruby-gem
I've cloned their sinatra app and it runs fine. However, I want to be able to use every option provided, for example, user search.
The only photo feeds that I've gotten to work has been user_recent_media as shown below and media_popular. I did so by simply swapping the two methods.
Instagram's API shows a simple puts method in their example. How exactly can I get that to work so that I can use all their options such as search, location_recent_media, follows, etc.? What code in that example needs to be changed?
# Search for users on instagram, by name or username
puts Instagram.user_search("shayne sweeney")
# Get a list of media close to a given latitude and longitude
puts Instagram.media_search("37.7808851,-122.3948632")
get "/feed" do
client = Instagram.client(:access_token => session[:access_token])
user = client.user
html = "<h1>#{user.username}'s recent photos</h1>"
for media_item in client.user_recent_media
html << "<img src='#{media_item.images.thumbnail.url}'>"
end
html
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论