从instagram获取帖子时获取Farday::SSLError
。
我已推荐了此tutorial
下面是代码段
宝石文件
gem 'instagram'
config \ initializers \ instagram.rb
require "sinatra"
require "instagram"
Instagram.configure do |config|
config.client_id = "4ad05f8aa5a24827b6c5e3c825ff2528"
config.access_token = "06a7eb3dd2ec45d6a576e3b3576fc423"
end
homecontroller
def index
@galleries = Gallery.all
@banners = Slideshow.where(gallery_id: nil)
@instagram = Instagram.user_recent_media("592393738", {:count => 1})
end
index.html.erb
<% @instagram.each do |instagram| %>
<%= image_tag instagram.images.standard_resolution.url %>
<% end %>
答案 0 :(得分:0)
在视图中,将instagram.images.standard_resolution.url
替换为instagram.images.standard_resolution.url.sub(/^https?\:/, '')
或者,您可以尝试使用https://github.com/agilie/instagram_api_gem
这个宝石