我正在尝试构建一个小型rails应用程序,允许用户使用Instagram进行身份验证,然后访问他们自己的提要。我在挣扎!
我使用了omniauth instagram gem来获得基本的身份验证(当我登录时,我可以访问我的名字和UID)。
但是,任何访问我的提要的尝试都会导致错误,这些错误提到了访问令牌是必需的。
我刚刚偶然发现了'instagram-api‘的创业板,我即将使用它。但是作为一个红宝石n00b,我不知道如何在控制器中实现示例(Sinatra)代码:
# Instantiate a new client.
client = Instagram.client(
:client_id => '2bfe9d72a4aae8f06a31025b7536be80',
:client_secret => '9d667c2b7fae7a329f32b6df17926154',
:callback_url => 'http://example.com/'
)
# Visit the authorization URL in your browser and login.
client.authorize_url
# => "https://api.instagram.com/oauth/authorize/?client_id=2bfe9d72a4aae8f06a31025b7536be80&redirect_uri=http://example.com/&response_type=code"
# Retrieve the code from the URL parameters and use it to get an access token.
client.get_access_token('88fb89ab65454da2a06f2c6dacd09436')
# => '1313345.3fedf64.a0fcb7f40e02fe3da50500'有人能帮忙吗?
发布于 2013-12-30 04:05:30
尝试一下我使用过并且支持得很好的instagram-红宝石。
发布于 2013-12-30 03:15:43
您可以按照这些手动指令检索访问令牌,然后将其存储为环境变量,以便在应用程序中引用。
不过,不知道如何在控制器内自动完成所有这些操作。
https://stackoverflow.com/questions/20313674
复制相似问题