hanklords / flickraw Goto Github PK
View Code? Open in Web Editor NEWRuby library to access flickr api.
Home Page: http://hanklords.github.com/flickraw/
License: MIT License
Ruby library to access flickr api.
Home Page: http://hanklords.github.com/flickraw/
License: MIT License
elise@cpu-2:~/Development/clients/memoryreel/Mreel-Mongo staging$ irb
irb(main):001:0> require 'rubygems'
require 'flick=> true
irb(main):002:0> require 'flickraw'
FlickRaw::FailedResponse: 'flickr.reflection.getMethods' - Invalid API Key (Key has expired)
I am working on a Rails Project which needs integration with Flickr to get most recent public images. I am using flickraw for Flickr integration. In order to develop rspec tests and cucumber features, I need to mock Flickr Calls to avoid web calls and I found takaltoo/flickrmocks.
Flickr has updated their APIs, however, takaltoo/flickrmocks doesn't seem to be updated as per the new API specifications.
Is there any way I can do some mocking using flickraw itself. There is a way to mock the underlying web calls and return the expected response. Just looking for a clean and better way.
I want to make sure it still works on Ruby 1.9 without the json gem.
I do: rake test
, but I get errors saying: Invalid API Key
I have an API Key, but where do I set it to run the tests?
There is a small typo in the README.rdoc. In your configuration example the config hash is called FlickrawOptions
, when it should be FlickRawOptions
.
i get FlickRaw::OAuth::FailedResponse (token_rejected) with rails in response to
FlickRaw.api_key= FLICKR_APP_ID
FlickRaw.shared_secret= FLICKR_APP_SECRET
if params[:oauth_token]
token = session[:flickr_token]
flickr.get_access_token(token[:oauth_token], token[:oauth_token_secret], params[:oauth_verifier])
@flickr_user = flickr.test.login.username
else
token = flickr.get_request_token(:oauth_callback => "XXXXX")
session[:flickr_token] = @token
flickr_url = flickr.get_authorize_url(token['oauth_token'], :perms => 'read')
end
I believe there's a bug in the url_x
(where x
is: n
, s
, or something else) methods. Whenever I call the following:
FlickRaw.url_n(photoset)
I get a URL which looks like the following: http://farm9.staticflickr.com/8499/72157632367381040_eda82f692f_n.jpg. This results in the "This image or video is currently unavailable." Flickr image. As far as I can see, this is because of the fact that it contains the ID
of the photoset instead of the value of the primary
field.
In that URL 72157632367381040
is the ID of my photoset. When I replace that with the primary
value. I get the following URL: http://farm9.staticflickr.com/8499/8318972536_eda82f692f_n.jpg, which results in the correct image.
I'll try to look into this when I get the time, if it hasn't been fixed by then.
For uploading videos with flickraw, I need to set the timeout value to nil (no timeout). However, flickraw only forwards that timeout value to the Http class if it's not nil:
I propose you change the following code
http.read_timeout = FlickRawOptions['timeout'] if FlickRawOptions['timeout']
to
http.read_timeout = FlickRawOptions['timeout'] if FlickRawOptions.key?('timeout')
I worked around this issue in ruby 1.9.1 by setting the timeout to 0 (not nil), but in ruby 1.9.2 this results in immediate timeouts. I think they changed/reimplemented the socket class in 1.9.2, which would explain the difference in behavior here.
In Ruby 2.1.0, I see this warning from the OpenSSL call within FlickRaw:
Digest::Digest is deprecated; use Digest
I get the following segfault message after running get.rb:
(eval):1: [BUG] Segmentation fault
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.7.0]
-- control frame ----------
c:0032 p:0018 s:0127 b:0127 l:000126 d:000126 CLASS (eval):1
c:0031 p:0008 s:0125 b:0125 l:000116 d:000124 EVAL (eval):1
c:0030 p:---- s:0123 b:0123 l:000122 d:000122 FINISH
c:0029 p:---- s:0121 b:0121 l:000120 d:000120 CFUNC :eval
c:0028 p:0046 s:0117 b:0117 l:000116 d:000116 METHOD /usr/local/lib/ruby/gems/1.9.1/gems/flickraw-0.9.4/lib/flickraw/response.rb:27
c:0027 p:---- s:0111 b:0111 l:000110 d:000110 FINISH
c:0026 p:---- s:0109 b:0109 l:000108 d:000108 CFUNC :new
c:0025 p:0139 s:0104 b:0104 l:000103 d:000103 METHOD /usr/local/lib/ruby/gems/1.9.1/gems/flickraw-0.9.4/lib/flickraw/response.rb:11
c:0024 p:0021 s:0098 b:0098 l:000078 d:000097 BLOCK /usr/local/lib/ruby/gems/1.9.1/gems/flickraw-0.9.4/lib/flickraw/response.rb:22
c:0023 p:---- s:0095 b:0095 l:000094 d:000094 FINISH
c:0022 p:---- s:0093 b:0093 l:000092 d:000092 CFUNC :collect
c:0021 p:0089 s:0090 b:0088 l:000078 d:000087 BLOCK /usr/local/lib/ruby/gems/1.9.1/gems/flickraw-0.9.4/lib/flickraw/response.rb:22
c:0020 p:---- s:0084 b:0084 l:000083 d:000083 FINISH
c:0019 p:---- s:0082 b:0082 l:000081 d:000081 CFUNC :each
c:0018 p:0030 s:0079 b:0079 l:000078 d:000078 METHOD /usr/local/lib/ruby/gems/1.9.1/gems/flickraw-0.9.4/lib/flickraw/response.rb:19
c:0017 p:---- s:0073 b:0073 l:000072 d:000072 FINISH
c:0016 p:---- s:0071 b:0071 l:000070 d:000070 CFUNC :new
c:0015 p:0139 s:0066 b:0066 l:000065 d:000065 METHOD /usr/local/lib/ruby/gems/1.9.1/gems/flickraw-0.9.4/lib/flickraw/response.rb:11
c:0014 p:0333 s:0060 b:0060 l:000059 d:000059 METHOD /usr/local/lib/ruby/gems/1.9.1/gems/flickraw-0.9.4/lib/flickraw/api.rb:137
c:0013 p:0096 s:0050 b:0050 l:000049 d:000049 METHOD /usr/local/lib/ruby/gems/1.9.1/gems/flickraw-0.9.4/lib/flickraw/api.rb:56
c:0012 p:0019 s:0042 b:0042 l:000041 d:000041 METHOD (eval):3
c:0011 p:0036 s:0037 b:0037 l:001be8 d:000036 BLOCK get.rb:37
c:0010 p:0008 s:0032 b:0032 l:000023 d:000031 BLOCK /usr/local/lib/ruby/gems/1.9.1/gems/flickraw-0.9.4/lib/flickraw/response.rb:41
c:0009 p:---- s:0029 b:0029 l:000028 d:000028 FINISH
c:0008 p:---- s:0027 b:0027 l:000026 d:000026 CFUNC :each
c:0007 p:0013 s:0024 b:0024 l:000023 d:000023 METHOD /usr/local/lib/ruby/gems/1.9.1/gems/flickraw-0.9.4/lib/flickraw/response.rb:41
c:0006 p:0077 s:0021 b:0021 l:001be8 d:000020 BLOCK get.rb:35
c:0005 p:---- s:0016 b:0016 l:000015 d:000015 FINISH
c:0004 p:---- s:0014 b:0014 l:000013 d:000013 CFUNC :each
c:0003 p:0178 s:0011 b:0011 l:001be8 d:0005a0 EVAL get.rb:30
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:001be8 d:001be8 TOP
---------------------------
-- Ruby level backtrace information ----------------------------------------
get.rb:30:in `<main>'
get.rb:30:in `each'
get.rb:35:in `block in <main>'
/usr/local/lib/ruby/gems/1.9.1/gems/flickraw-0.9.4/lib/flickraw/response.rb:41:in `each'
/usr/local/lib/ruby/gems/1.9.1/gems/flickraw-0.9.4/lib/flickraw/response.rb:41:in `each'
/usr/local/lib/ruby/gems/1.9.1/gems/flickraw-0.9.4/lib/flickraw/response.rb:41:in `block in each'
get.rb:37:in `block (2 levels) in <main>'
(eval):3:in `getExif'
/usr/local/lib/ruby/gems/1.9.1/gems/flickraw-0.9.4/lib/flickraw/api.rb:56:in `call'
/usr/local/lib/ruby/gems/1.9.1/gems/flickraw-0.9.4/lib/flickraw/api.rb:137:in `process_response'
/usr/local/lib/ruby/gems/1.9.1/gems/flickraw-0.9.4/lib/flickraw/response.rb:11:in `build'
/usr/local/lib/ruby/gems/1.9.1/gems/flickraw-0.9.4/lib/flickraw/response.rb:11:in `new'
/usr/local/lib/ruby/gems/1.9.1/gems/flickraw-0.9.4/lib/flickraw/response.rb:19:in `initialize'
/usr/local/lib/ruby/gems/1.9.1/gems/flickraw-0.9.4/lib/flickraw/response.rb:19:in `each'
/usr/local/lib/ruby/gems/1.9.1/gems/flickraw-0.9.4/lib/flickraw/response.rb:22:in `block in initialize'
/usr/local/lib/ruby/gems/1.9.1/gems/flickraw-0.9.4/lib/flickraw/response.rb:22:in `collect'
/usr/local/lib/ruby/gems/1.9.1/gems/flickraw-0.9.4/lib/flickraw/response.rb:22:in `block (2 levels) in initialize'
/usr/local/lib/ruby/gems/1.9.1/gems/flickraw-0.9.4/lib/flickraw/response.rb:11:in `build'
/usr/local/lib/ruby/gems/1.9.1/gems/flickraw-0.9.4/lib/flickraw/response.rb:11:in `new'
/usr/local/lib/ruby/gems/1.9.1/gems/flickraw-0.9.4/lib/flickraw/response.rb:27:in `initialize'
/usr/local/lib/ruby/gems/1.9.1/gems/flickraw-0.9.4/lib/flickraw/response.rb:27:in `eval'
(eval):1:in `initialize'
(eval):1:in `singletonclass'
-- C level backtrace information -------------------------------------------
[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html
Abort trap: 6
I direct user to the URL generated by
flickr.get_request_token :oauth_callback => flickr_callback_image_import_url
After authorizing user is sent to this callback action
def flickr_callback
token = FlickRaw::Flickr.new.get_request_token :oauth_callback => flickr_callback_image_import_url
raw_token = flickr.get_access_token(token['oauth_token'], token['oauth_token_secret'], params[:oauth_verifier])
end
I get a 'token rejected' response from the flickr.get_access_token
call every time. Can someone point me towards what I am doing wrong? I'd really appreciate it.
Hi,
I can't work this out. I'm simply trying with your first authenticated example. The first example, without authentication is working.
I have this code, running in a Ruby 1.9.2 environment, with FlickRaw installed through gem install flickraw
in a dedicated RVM gemset:
require 'flickraw'
FlickRaw.api_key="ok_i_replaced_with_my_key"
FlickRaw.shared_secret="same_with_my_secret"
token = flickr.get_request_token(:perms => 'delete')
Running this, I already have a blocking issue: NoMethodError: undefined method
get_request_token' for #FlickRaw::Flickr:0x00000101180158`
I must have missed something somewhere, but what?
Thanks in advance,
Regards,
Romain
Flickr will be switching off the HTTP endpoints at some point.
http://code.flickr.net/2014/02/24/new-ssl-endpoints-for-the-flickr-api/
I see flickraw supports HTTPS but it's not the default (as far as I can tell).
Can it be made the default please?
Flickraw is adding a significant amount of time to my test suite whenever I'm running focused tests. Could you add a flag to disable the loading of methods when in the test environment?
Hi!
I randomly get an encoding error, here is the stack trace:
Encoding::CompatibilityError: incompatible character encodings: ASCII-8BIT and UTF-8
from /home/deploy/apps/app/shared/bundle/ruby/1.9.1/bundler/gems/flickraw-15e07ed90020/lib/flickraw/oauth.rb:110:in `block (2 levels) in post_multipart'
from /home/deploy/apps/app/shared/bundle/ruby/1.9.1/bundler/gems/flickraw-15e07ed90020/lib/flickraw/oauth.rb:101:in `each'
from /home/deploy/apps/app/shared/bundle/ruby/1.9.1/bundler/gems/flickraw-15e07ed90020/lib/flickraw/oauth.rb:101:in `block in post_multipart'
from /home/deploy/apps/app/shared/bundle/ruby/1.9.1/bundler/gems/flickraw-15e07ed90020/lib/flickraw/oauth.rb:152:in `block in post'
from /home/deploy/.rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/net/http.rb:745:in `start'
from /home/deploy/apps/app/shared/bundle/ruby/1.9.1/bundler/gems/flickraw-15e07ed90020/lib/flickraw/oauth.rb:147:in `post'
from /home/deploy/apps/app/shared/bundle/ruby/1.9.1/bundler/gems/flickraw-15e07ed90020/lib/flickraw/oauth.rb:96:in `post_multipart'
from /home/deploy/apps/app/shared/bundle/ruby/1.9.1/bundler/gems/flickraw-15e07ed90020/lib/flickraw/api.rb:145:in `upload_flickr'
from /home/deploy/apps/app/shared/bundle/ruby/1.9.1/bundler/gems/flickraw-15e07ed90020/lib/flickraw/api.rb:91:in `upload_photo'
from /home/deploy/apps/app/releases/20130805072010/app/platforms/flickr/photo.rb:16:in `block in share!'
from /home/deploy/apps/app/releases/20130805072010/app/platforms/platform/photo.rb:42:in `cache_image'
from /home/deploy/apps/app/releases/20130805072010/app/platforms/flickr/photo.rb:5:in `share!'
from /home/deploy/apps/app/releases/20130805072010/app/models/share.rb:34:in `share!'
from (irb):5
from /home/deploy/apps/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands/console.rb:47:in `start'
from /home/deploy/apps/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in `start'
from /home/deploy/apps/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I've not managed to track down the line where this happens, or even reproduce the errors. It's just something that happens occasionally but when it happens it happens again given the same parameters.
Here is the part of my code where I call it. I've appended a fore_encoding to every String parameter but the error is still happening.
def share!
is_public = Rails.env.production? ? 1 : 0
cache_image do |image|
uri = URI.parse(image)
mime_type = MIME::Types.type_for(uri.path).first.content_type.force_encoding('UTF-8')
filename = uri.path.split('/').last.force_encoding('UTF-8')
file = File.open(image)
safety_level = 1
if @photo.contains_adult_content?
safety_level = 3
end
@base.flickraw.upload_photo UploadIO.new(file, mime_type, filename),
title: @photo.title.force_encoding('UTF-8'),
description: @photo.description.force_encoding('UTF-8'),
tags: @photo.tag_list.each{ |t| t.gsub!(/\s/,'').force_encoding('UTF-8') }.join(' '),
is_public: is_public,
content_type: 1,
safety_level: safety_level
end
end
Is there support for geo.getLocation? http://www.flickr.com/services/api/flickr.photos.geo.getLocation.html
according to the flickr docs, the tags should be able to do "-people" and exclude that tag. however when i have :tags => '-people' as part of the search arguments, i get a result set of photos who have that tag associated with it.
Using 0.9.2 with example code (only modified to add API key).
$ ruby examples/auth.rb
/Users/mroth/.rvm/gems/ruby-1.9.2-p290/gems/flickraw-0.9.2/lib/flickraw/oauth.rb:125:in `post': wrong number of arguments (3 for 4) (ArgumentError)
from /Users/mroth/.rvm/gems/ruby-1.9.2-p290/gems/flickraw-0.9.2/lib/flickraw/oauth.rb:64:in `request_token'
from /Users/mroth/.rvm/gems/ruby-1.9.2-p290/gems/flickraw-0.9.2/lib/flickraw/api.rb:61:in `get_request_token'
from examples/auth.rb:10:in `<main>'
Since updating to the new version, I get this error when requiring flickraw in any script. See output here when trying to run example scripts.
mroth-imac ~:$ gem install flickraw
Fetching: flickraw-0.9.1.gem (100%)
Successfully installed flickraw-0.9.1
1 gem installed
mroth-imac ~:$ ruby examples/interestingness.rb
/Users/mroth/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- flickraw/oauth (LoadError)
from /Users/mroth/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/mroth/.rvm/gems/ruby-1.9.2-p290/gems/flickraw-0.9.1/lib/flickraw.rb:2:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:33:in `require'
from <internal:lib/rubygems/custom_require>:33:in `rescue in require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from examples/interestingness.rb:1:in `<main>'
mroth-imac ~:$ ruby examples/auth.rb
/Users/mroth/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- flickraw/oauth (LoadError)
from /Users/mroth/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/mroth/.rvm/gems/ruby-1.9.2-p290/gems/flickraw-0.9.1/lib/flickraw.rb:2:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:33:in `require'
from <internal:lib/rubygems/custom_require>:33:in `rescue in require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from examples/auth.rb:1:in `<main>'
So far as I can tell url_m() is returning the small sized photo, and url_s is returning the thumbnail sized photo. This could just be me misunderstanding flickr's size designations though.
EDIT
I think I sorted this out. I wanted to access the size flickr calls medium 500 but you get there by using regular url() without an underscore designation.
flickr is totally down right now.
The exception is happening in open_flickr in flickraw.rb
http://gist.github.com/214440 for full stacktrace.
Whenever I try to get a request token using:
FlickRaw.api_mkey = consumer_key
FlickRaw.shared_secret = consumer_secret
token = flickr.get_request_token(:perms => 'delete')
It throws an exception: "NameError (undefined local variable or method `token_secret' for #FlickRaw::OAuth:0x1f3f068)"
After looking through your code I think the problem comes from:
def request_token(url, oauth_params = {})
r = post_form(url, token_secret, {:oauth_callback => "oob"}.merge(oauth_params))
OAuth.parse_response(r.body)
end
because token_secret isn't defined. When I replaced it with @consumer_secret it gave me an error about the signature not being valid.
There was a small mistake in commit eb69606, 2009-11-11.
In flickraw.rb, lines 177 and 184 (upload_photo and replace_photo), args was overwritten with {} in the call to upload_flickr.
I'm happy to see that these functions are implemented!
Flickr.people.getPhotos returns a Flickraw.ResponseList
Flickr.photosets.getPhotos returns a Flickraw.Response -- in exactly the same format as above.
Is this intentional? It's messing up our code a bit, since we were calling .to_a on the ResponseList but then if we get try to photos from a set, it has no .to_a method.
Cc @pozorvlak
Object returns owner id, but what is the best way to get the username?
http://www.flickr.com/services/api/replace.api.html
I'm not sure if this is already in, couldn't find it. I'll dig into the code a bit and implement it myself if it's not there. I'm posting the issue just to let people know I'm working on this. (I see lots of forks but not many merges though; what's the protocol for collaboration?)
I hope I haven't missed something here, but I've got a simple use case which will always make a simple test app fail.
You can get the app here: http://github.com/olance/flickraw-test
It is really simple: it asks for authentication, associates the token to the User model and then shows the photos with some pagination.
The problem shows when you revoke the permission from your Flickr account, while already authorized on the app. The index action will then have a FlickRaw::FailedResponse exception raised on refresh, so it will redirect to the auth page again.
There, the flickr.auth.getFrob call also raises a FlickRaw::FailedResponse, with message "Invalid auth token". According to the Flickr API, this error should never come up on a call to getFrob.
From my understanding of your code, it looks like the token is always passed as a parameter when it is not nil, which seems to be a problem when calling a method that doesn't require it.
I think the simplest thing would be to provide an accessor on auth_token, allowing to reset the token?
Thus I could set flickr.auth_token = nil when checkToken fails, and call getFrob again without failure.
I couldn't connect with 0.9.3 but 0.9 was fine.
FlickRaw.api_key="8a8.....5aa0a"
=> "8......05aa0a"
FlickRaw.shared_secret="11...684b"
=> "11....4b"
?> flickr
ArgumentError: wrong number of arguments (7 for 6)
from /Library/Ruby/Gems/1.8/gems/flickraw-0.9.3/lib/flickraw/oauth.rb:134:instart' from /Library/Ruby/Gems/1.8/gems/flickraw-0.9.3/lib/flickraw/oauth.rb:134:in
post'
from /Library/Ruby/Gems/1.8/gems/flickraw-0.9.3/lib/flickraw/oauth.rb:81:inpost_form' from /Library/Ruby/Gems/1.8/gems/flickraw-0.9.3/lib/flickraw/api.rb:52:in
call'
from /Library/Ruby/Gems/1.8/gems/flickraw-0.9.3/lib/flickraw/api.rb:43:ininitialize' from /Library/Ruby/Gems/1.8/gems/flickraw-0.9.3/lib/flickraw.rb:17:in
new'
from /Library/Ruby/Gems/1.8/gems/flickraw-0.9.3/lib/flickraw.rb:17:in `flickr'
from (irb):6
I love flickraw. I am trying to get it to work with ruby1.9, and get the following error when loading an app that requires flickraw:
/opt/local/lib/ruby1.9/gems/1.9.1/gems/flickraw-0.5.1/lib/flickraw.rb:24:in `require’: no such file to load — md5 (LoadError)
thanks for your great work on this project!
This gem creates an unscoped flickr method. It interferes with scopes and other things of the same name. It ends up causing this exception:
"RuntimeError: No API key or secret defined !"
I was able to get around that error by moving the require line from outside the class to inside a method declaration.
Hello,
flickraw cannot use Japanese, maybe after this change.
#39
/Users/xxxxx/.rvm/gems/ruby-1.8.7-p357/gems/flickraw-0.9.5/lib/flickraw/oauth.rb:151:in
post': signature_invalid (FlickRaw::OAuthClient::FailedResponse) from /Users/xxxxx/.rvm/gems/ruby-1.8.7-p357/gems/flickraw-0.9.5/lib/flickraw/oauth.rb:86:in
post_form'
from /Users/xxxxx/.rvm/gems/ruby-1.8.7-p357/gems/flickraw-0.9.5/lib/flickraw/api.rb:53:incall' from (eval):3:in
editMeta'
from /Users/xxxxx/Documents/Aptana Studio 3 Workspace/flickr/flickr.rb:97
from /Users/xxxxx/Documents/Aptana Studio 3 Workspace/flickr/flickr.rb:95:in `each'
from /Users/xxxxx/Documents/Aptana Studio 3 Workspace/flickr/flickr.rb:95
using this monkey patch, it's ok.
require "flickraw"
module FlickRaw
class OAuthClient
class << self
def escape(v); URI.escape(v.to_s, /[^a-zA-Z0-9\-\.\_\~]/) end
end
end
end
Thanks,
kinumi
Seems to break on: require 'json'
If you have the require, is it worth adding it to your gemspec?
Bundler.require
LoadError: no such file to load -- json
from /Library/Ruby/Gems/1.8/gems/flickraw-0.9/lib/flickraw.rb:24:inrequire' from /Library/Ruby/Gems/1.8/gems/flickraw-0.9/lib/flickraw.rb:24 from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:64:in
require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:64:inrequire' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:62:in
each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:62:inrequire' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:51:in
each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:51:inrequire' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler.rb:112:in
require'
from (irb):1
Thanks,
Dan
i follow the steps from Usage Sample
irb(main):001:0> require "flickraw" => true irb(main):002:0> list = flickr.photos.getRescent FlickRaw::FailedResponse: 'flickr.reflection.getMethods' - Invalid API Key (Key has invalid format)
add below to README.doc in Usage Sample
FlickRaw.api_key="... Your API key ..." FlickRaw.shared_secret="... Your shared secret ..."
then it works.
I get following error with ruby 1.9.1 and flickraw 0.6:
/opt/local/lib/ruby1.9/gems/1.9.1/gems/flickraw-0.6/lib/flickraw.rb:233:in `api_sig': uninitialized constant Module::MD5 (NameError)
I saw in few another libraries that MD5 become Digest::MD5.
Hope you can help,
Thanks.
My project hosted on heroku (heroku.com) was running fine locally on ruby 1.9.1 but was crashing on heroku on ruby 1.9.1. After several back and forth messages between heroku support and myself we eventually found the problem inside build_args.
Basically what it boils down to is that on ruby 1.9.1's Net::HTTP's Request#set_form_data (which is what the results from build_args get passed to ) does not support symbols as key names and expects strings. The result is a crash like this:
TypeError - can't dup Symbol:
/usr/ruby1.9.1/lib/ruby/1.9.1/net/http.rb:1529:in `dup'
/usr/ruby1.9.1/lib/ruby/1.9.1/net/http.rb:1529:in `urlencode'
/usr/ruby1.9.1/lib/ruby/1.9.1/net/http.rb:1524:in `block in encode_kvpair'
/usr/ruby1.9.1/lib/ruby/1.9.1/net/http.rb:1524:in `map'
/usr/ruby1.9.1/lib/ruby/1.9.1/net/http.rb:1524:in `encode_kvpair'
/usr/ruby1.9.1/lib/ruby/1.9.1/net/http.rb:1517:in `block in set_form_data'
/usr/ruby1.9.1/lib/ruby/1.9.1/net/http.rb:1517:in `each'
/usr/ruby1.9.1/lib/ruby/1.9.1/net/http.rb:1517:in `map'
/usr/ruby1.9.1/lib/ruby/1.9.1/net/http.rb:1517:in `set_form_data'
/home/slugs/230721_f0c96b5_e2e4/mnt/.gems/gems/flickraw-0.8.3/lib/flickraw.rb:162:in `block in call'
/home/slugs/230721_f0c96b5_e2e4/mnt/.gems/gems/flickraw-0.8.3/lib/flickraw.rb:205:in `block in open_flickr'
I've managed to "Monkey Patch" my own project for now by using the following code before I use any FlickRaw code:
module FlickRaw
class Flickr
alias :broken_build_args :build_args
def build_args(args={}, req = nil)
Hash[*broken_build_args(args,req).map{|key,val|[key.to_s,val]}.flatten]
end
end
end
However this is not ideal and I think the build_args function should be changed to use strings rather than symbols for it's keys.
Flickr documentation says you can comma separate licenses in a photo search and it will search by all of them, however :license => '1,2,3,4' in flickraw isn't working. Any ideas? Thanks in advance!
I get the following error when running FlickRaw:
/usr/local/lib/ruby/gems/1.9.1/gems/flickraw-0.9.5/lib/flickraw/api.rb:54: warning: instance variable @access_secret not initialized
I took a look at api.rb
and could implement a patch, but in several different ways. I'm a beginner/intermediate rubyist, so I thought I'd ask you to fix it the way you think is best. Thanks!
Not sure if this is the right place for this issue...
I tried to use Flickraw-cached gem, but calling flickr.people.getPhotos always raises a NoMethodError exception:
NoMethodError (undefined method `getPhotos' for #FlickRaw::Flickr::People:0x102ee52c0)
Switching to the regular Flickraw gem resolved the problem.
It seems as though the file is not closed once it is uploaded.
This can be handled outside Flickraw when passing an I/O stream, but if passing a file path instead it cannot be.
SInce my upgrade to flickraw 0.9 I get this error for authenticated requests:
/Library/Ruby/Gems/1.8/gems/flickraw-0.9/lib/flickraw.rb:79:in 'gen_nonce': uninitialized constant FlickRaw::OAuth::OpenSSL (NameError)
from /Library/Ruby/Gems/1.8/gems/flickraw-0.9/lib/flickraw.rb:82:in 'gen_default_params'
from /Library/Ruby/Gems/1.8/gems/flickraw-0.9/lib/flickraw.rb:104:in 'post_form'
from /Library/Ruby/Gems/1.8/gems/flickraw-0.9/lib/flickraw.rb:286:in 'call'
from /Library/Ruby/Gems/1.8/gems/flickraw-0.9/lib/flickraw.rb:278:in 'initialize'
from /Library/Ruby/Gems/1.8/gems/flickraw-0.9/lib/flickraw.rb:426:in 'new'
from /Library/Ruby/Gems/1.8/gems/flickraw-0.9/lib/flickraw.rb:426:in 'flickr'
from /Users/gato/Desktop/testflickr.rb:11
I'm on Mac OS X Lion. Before the upgrade everything worked perfect.
What am I doing wrong?
Regards,
gato
Recently I started seeing this exception:
795: unexpected token at ''
/usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/json-1.8.0/lib/json/common.rb:155:in `parse'
/usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/json-1.8.0/lib/json/common.rb:155:in `parse'
/usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/json-1.8.0/lib/json/common.rb:334:in `load'
/usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/flickraw-0.9.6/lib/flickraw/api.rb:137:in `process_response'
/usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/flickraw-0.9.6/lib/flickraw/api.rb:63:in `call'
/usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/flickraw-0.9.6/lib/flickraw/api.rb:44:in `initialize'
/usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/flickraw-0.9.6/lib/flickraw.rb:17:in `new'
/usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/flickraw-0.9.6/lib/flickraw.rb:17:in `flickr'
Looking at tcpdump it seemed to be failing on a POST to http://api.flickr.com/services/rest/
with a Content-Encoding: gzip
response header.
In flickraw/api.rb it seems to be passing the body of the http response directly to process_response without gunzipping it.
Hi, I am getting this error when I load (require) flickraw.
/Library/Ruby/Gems/1.8/gems/flickraw-0.8/lib/flickraw.rb:166:in call:NoMethodError: private method load called for JSON:Module
I think on line 166 you should call JSON.parse and not JSON.load
Hello,
I've been trying to follow the readme's Authentication chapter precisely, for a rails site, and noticed that on the following circumstances:
flickraw falls with "stack level too deep" when trying to fetch a token (flickr.auth.getToken :frob => params[:frob]). Changing the call to FlickRaw::Flickr.new.auth.getToken works as expected (authentication passes).
Though I am not sure if this is indeed flickraw issue, I'd like to ask for a bit more clarification on how to use flickraw for rails, if that's possible?
What I am doing now for rails 2.3.4 is:
environment.rb:
config.gem "flickraw", :version => '>= 0.7.1', :source => "http://gems.github.com"
initialisers/flickraw.rb:
FlickRaw.api_key = 'blah'
FlickRaw.shared_secret = 'blah'
controllers/application_controller.rb
require 'flickraw' # this is actually the only place where it is declared
def get_flickr
FlickRaw::Flickr.new
end
And anywhere I need an API call:
get_flickr.make.a.call()
And I feel that I am doing something wrong... Especially assuming that library lazy loading should be utilised somehow somewhere... But for me this configuration at least works. Again, could someone please provide a short clarification on using flickraw with current production rails? Many thanks in advance!
D:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:146:in `rescue in rbuf_fill': Timeout:
:Error (Timeout::Error)
from D:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:140:in `rbuf_fill'
from D:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil'
from D:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:132:in `readline'
from D:/Ruby193/lib/ruby/1.9.1/net/http.rb:2562:in `read_status_line'
from D:/Ruby193/lib/ruby/1.9.1/net/http.rb:2551:in `read_new'
from D:/Ruby193/lib/ruby/1.9.1/net/http.rb:1319:in `block in transport_r
equest'
from D:/Ruby193/lib/ruby/1.9.1/net/http.rb:1316:in `catch'
from D:/Ruby193/lib/ruby/1.9.1/net/http.rb:1316:in `transport_request'
from D:/Ruby193/lib/ruby/1.9.1/net/http.rb:1293:in `request'
from D:/Ruby193/lib/ruby/gems/1.9.1/gems/flickraw-0.9.6/lib/flickraw/oau
th.rb:153:in `block in post'
from D:/Ruby193/lib/ruby/1.9.1/net/http.rb:745:in `start'
from D:/Ruby193/lib/ruby/gems/1.9.1/gems/flickraw-0.9.6/lib/flickraw/oau
th.rb:147:in `post'
from D:/Ruby193/lib/ruby/gems/1.9.1/gems/flickraw-0.9.6/lib/flickraw/oau
th.rb:96:in `post_multipart'
from D:/Ruby193/lib/ruby/gems/1.9.1/gems/flickraw-0.9.6/lib/flickraw/api
.rb:138:in `upload_flickr'
from D:/Ruby193/lib/ruby/gems/1.9.1/gems/flickraw-0.9.6/lib/flickraw/api
.rb:90:in `upload_photo'
When I call:
frob = flickr.auth.getFrob
Any ideas?
TypeError (can't dup Symbol):
/usr/ruby1.9.1/lib/ruby/1.9.1/net/http.rb:1529:in dup' /usr/ruby1.9.1/lib/ruby/1.9.1/net/http.rb:1529:in
urlencode'
/usr/ruby1.9.1/lib/ruby/1.9.1/net/http.rb:1524:in block in encode_kvpair' /usr/ruby1.9.1/lib/ruby/1.9.1/net/http.rb:1524:in
map'
/usr/ruby1.9.1/lib/ruby/1.9.1/net/http.rb:1524:in encode_kvpair' /usr/ruby1.9.1/lib/ruby/1.9.1/net/http.rb:1517:in
block in set_form_data'
/usr/ruby1.9.1/lib/ruby/1.9.1/net/http.rb:1517:in each' /usr/ruby1.9.1/lib/ruby/1.9.1/net/http.rb:1517:in
map'
/usr/ruby1.9.1/lib/ruby/1.9.1/net/http.rb:1517:in set_form_data' .gems/gems/flickraw-0.8.3/lib/flickraw.rb:162:in
block in call'
.gems/gems/flickraw-0.8.3/lib/flickraw.rb:205:in block in open_flickr' /usr/ruby1.9.1/lib/ruby/1.9.1/net/http.rb:564:in
start'
/usr/ruby1.9.1/lib/ruby/1.9.1/net/http.rb:453:in start' .gems/gems/flickraw-0.8.3/lib/flickraw.rb:203:in
open_flickr'
.gems/gems/flickraw-0.8.3/lib/flickraw.rb:160:in call' .gems/gems/flickraw-0.8.3/lib/flickraw.rb:150:in
initialize'
.gems/gems/flickraw-0.8.3/lib/flickraw.rb:317:in new' .gems/gems/flickraw-0.8.3/lib/flickraw.rb:317:in
flickr'
app/controllers/flickrs_controller.rb:89:in `new'
hello hanklords~
Thanks for your flickr lib ,
When I use upload method , I have a problem as below
ArgumentError (wrong number of arguments (1 for 0)):
app/controllers/news_controller.rb:72:in `upload_photo'
This is my upload.html.haml
=form_tag ({:action => :upload_photo},:multipart => true )do
= hidden_field_tag :token, @upload_info[:token]
= label_tag "Upload Photo"
= file_field_tag :photo
= submit_tag "Upload Photo"
And My controller is
def upload_photo
FlickRaw.api_key=FlickrawConfig.key
FlickRaw.shared_secret=FlickrawConfig.shared_secret
flickr.upload_photo params[:photo] ,:title => "Title", :description => "This is the description"
Sorry to bother you ,
If it is possible , maybe a easy demo will help novice like me ~ thanks
like youtube_it :
Example Rails 3 App
You can get an example how you can use youtube_it with Rails 3 here: github.com/chebyte/youtube_it_rails_app_example
Hi, I see stuff in the code for OAuth - is it all ready to use?
I ask as there's no mention in the main readme or the examples.
Folks on the Flickr API group are getting antsy about the potential end of the old authentication mechanism.
I'm ready to move my stuff over if/when Flickraw supports it.
If it is all working, some examples would be really useful.
Thanks, Darren.
Please update the code & documentation to use the new way of defining a Hash in Ruby 1.9, e.g.,
hash = {hello: world, nice: dude}
This is the call I'm making:
photos = flickr.photos.search(:user_id => 'me', :license => 4, :faves => 1, :contacts => "all")
it's the :contacts bit that does it; if i leave that off, it's fine. granted, your documentation says this:
Search your contacts. Either ‘all’ or ‘ff’ for just friends and family. (Experimental)
I also tried "ff" instead of "all" as mentioned in the docs, but the same error happens. This would be a really useful feature. I tried using the Pry debugger to see why in api.rb it was failing, but didn't get far.
/Users/dominick/.rvm/gems/ruby-1.9.3-p385/gems/flickraw-0.9.6/lib/flickraw/api.rb:127:in `process_response': 'flickr.photos.search' - Illogical arguments (FlickRaw::FailedResponse)
from /Users/dominick/.rvm/gems/ruby-1.9.3-p385/gems/flickraw-0.9.6/lib/flickraw/api.rb:54:in `call'
from (eval):3:in `search'
from flickraw_test.rb:75:in `get_creative_common_faves'
from flickraw_test.rb:92:in `<main>'
i have a question (as outlined by my colleague at http://stackoverflow.com/questions/4228252/rails-cache-and-un-dumpable-marshal-structures-how-to-cache-on-the-example-f )
how to cache flickraw responses with memcached and rails.cache?
i get an error when i try to Marshal.dump a flickraw response:
Marshal.dump(flickr.photos.getRecent)
produces: TypeError: singleton can't be dumped
any ideas or solutions for that?
thanks,
parasew
When I did gem install flickraw
, it installed the gem json-1.5.1. For Ruby 1.9, require 'json'
is supported out of the box, so is this necessary?
If not, please use something like gem "json", :platforms => [:ruby_18, :jruby, :mswin, :mingw_18]
in the Gemfile.
I like to keep my gem list as clean as possible. :)
Ref: http://gembundler.com/man/gemfile.5.html
Thanks!
Matt
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.