Faraday :: SSLError(SSL_connect返回= 1 errno = 0状态=错误:证书验证失败)

时间:2018-08-07 07:56:04

标签: ruby-on-rails ruby instagram instagram-api

从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 %>

1 个答案:

答案 0 :(得分:0)

在视图中,将instagram.images.standard_resolution.url替换为instagram.images.standard_resolution.url.sub(/^https?\:/, '')

或者,您可以尝试使用https://github.com/agilie/instagram_api_gem这个宝石