本文介绍了instagram宝石SessionController#index中的JSON :: ParserError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用instagram gem从我的instagram创建照片库.我正在按照以下示例尝试将gem集成到我的应用中,但是出现此错误

I am trying to use the instagram gem to create a gallery of photo from my instagram. I was following this example to try to integrate the gem in my app but keep running to this error

我们非常感谢您的帮助!

Any help is well appreciated!

这是我的控制器

class SessionController < ApplicationController

def index
 @item = Item.all
 @instagram = ::Instagram.user_recent_media('grateful4salvation', {:count => 2})
 end
end

Initializers/instagram.rb

Initializers/instagram.rb

require 'instagram'

 Instagram.configure do |config|
 config.client_id = ENV["CLIENT_ID"]
 config.access_token = ENV["access_token"]
 end

View/session/index.html

View/session/index.html

<% @instagram.each do |instagram| %>
  <%= image_tag instagram.images.standard_resolution.url %>
<% end %>

推荐答案

更改

@instagram = ::Instagram.user_recent_media('grateful4salvation', {:count => 2})

 @instagram = ::Instagram.user_recent_media( 'user_id', {:count => 2})

示例:

@instagram = ::Instagram.user_recent_media(1368150019, {:count => 2})

这篇关于instagram宝石SessionController#index中的JSON :: ParserError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 04:22