我想上传照片,但需要使用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
有人可以向我解释这段代码在做什么以及我应该如何使用它。
答案 0 :(得分:1)
首先,您应该打开http服务
rails server
在控制台上,您将看到
Open this url in your process to complete the authication process : http://xxxx.xxxx.xxxx.xxxx........
您必须复制该网址并将其发布在您的浏览器上。
登录后,您将获得一个号码,例如
xxx-xxx-xxx
只需将其复制到您的控制台上即可!
答案 1 :(得分:0)
此处详细介绍了整个过程 - http://www.flickr.com/services/api/auth.oauth.html
答案 2 :(得分:0)
我提交了一个拉取请求,但这里有一个更新的文档形式,应该更清楚
== Simple
+#Place near the top of your controller i.e. underneath FlickrController < ApplicationController
require 'flickraw'
+#Create an initializer file i.e. Flickr.rb and place it in config -> initializers folder
FlickRaw.api_key="... Your API key ..."
FlickRaw.shared_secret="... Your shared secret ..."
+#Examples of how the methods work
list = flickr.photos.getRecent
id = list[0].id
...