如何使用 Flickraw gem 向 flickr 进行身份验证
我想上传照片,但需要通过 flickr 进行身份验证才能上传。我正在使用 flickraw gem,但不明白下面的说明:
require 'flickraw'
FlickRaw.api_key="... Your API key ..."
FlickRaw.shared_secret="... Your shared secret ..."
token = flickr.get_request_token(:perms => 'delete')
auth_url = token['oauth_authorize_url']
puts "Open this url in your process to complete the authication process : #{auth_url}"
puts "Copy here the number given when you complete the process."
verify = gets.strip
begin
flickr.get_access_token(token['oauth_token'], token['oauth_token_secret'], verify)
login = flickr.test.login
puts "You are now authenticated as #{login.username}"
rescue FlickRaw::FailedResponse => e
puts "Authentication failed : #{e.msg}"
end
有人可以向我解释一下这段代码在做什么以及我应该如何使用它。
I want to upload a photo but need to authenticate with flickr in order to do so. I am using the flickraw gem but don't understand the instructions below:
require 'flickraw'
FlickRaw.api_key="... Your API key ..."
FlickRaw.shared_secret="... Your shared secret ..."
token = flickr.get_request_token(:perms => 'delete')
auth_url = token['oauth_authorize_url']
puts "Open this url in your process to complete the authication process : #{auth_url}"
puts "Copy here the number given when you complete the process."
verify = gets.strip
begin
flickr.get_access_token(token['oauth_token'], token['oauth_token_secret'], verify)
login = flickr.test.login
puts "You are now authenticated as #{login.username}"
rescue FlickRaw::FailedResponse => e
puts "Authentication failed : #{e.msg}"
end
Can someone explain to me what this code is doing and how I should use it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我提交了拉取请求,但这里是文档的更新形式,应该使这一点更加清晰
I submitted a pull request but here is an updated form of the documentation that should make this more clear
打开 http 服务
首先,您应该在控制台上
,您将看到必须复制 url 并将其发布到浏览器上。
登录后,您将获得一个号码,只需
将其复制到您的控制台即可!
First , you should open http service
On the Console , you will see
you have to copy the url and post it on your browser.
After log in , you will get a number , like
just copy it onto your console!
整个过程在这里详细描述 - http://www.flickr.com/服务/api/auth.oauth.html
The entire process is described in detail here - http://www.flickr.com/services/api/auth.oauth.html