Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrectly Signing arrays of source parameters for photosets #24

Open
codingjester opened this issue Sep 27, 2013 · 9 comments
Open

Incorrectly Signing arrays of source parameters for photosets #24

codingjester opened this issue Sep 27, 2013 · 9 comments

Comments

@codingjester
Copy link

It seems when migrating to using the built in Faraday OAuth functionality, the way we sign source arrays was broken. It seems that SimpleOAuth is double encoding the source arrays and we'll need to either mitigate this or patch it upstream.

@zachfeldman
Copy link

Any idea when a fix for this is coming out? Unfortunately reverting to earlier versions of the gem didn't seem to fix the issue.

@seejohnrun
Copy link

Here is a working example (NOTE: I did try this back when this ticket was issued and it didn't work out, so I'm thinking something along the way was fixed in the meantime):


If you use the Tumblr.new style:

# Load up creds (from wherever)
Tumblr.configure do |c|
  YAML.load_file(File.expand_path('~/.tumblr')).each do |k, v|
    c.send("#{k.to_sym}=", v)
  end
end

# Make a blog post with two photos
path1 = '<path as string>'
path2 = '<path as string>'
puts Tumblr.new.photo 'apeyes.tumblr.com', data: [path1, path2] # success

And if you use Tumblr::Client.new style (which I recommend):

# Load up creds
creds = {}.tap do |h|
  YAML.load_file(File.expand_path('~/.tumblr')).each do |k, v|
    h[k.to_sym] = v
  end
end
client = Tumblr::Client.new(creds)

# Make a blog post with two photos
path1 = '<path as string>'
path2 = '<path as string>'
puts client.photo 'apeyes.tumblr.com', data: [path1, path2]

@zachfeldman
Copy link

Nope, this only works with local files, not with URLs like it used to from my testing. Give this a go for instance:

cl = Tumblr.new
images = ["http://www.saawinternational.org/whale.jpg"]
cl.photo('funtesting.tumblr.com', {source: images})
>>{"status"=>401, "msg"=>"Not Authorized"}

I get a success when posting text or an image from a file locally.

@seejohnrun seejohnrun reopened this Dec 17, 2013
@seejohnrun
Copy link

Thanks for the code - will check this out tomorrow morning

@codingjester
Copy link
Author

@seejohnrun did we fix this ticket? Looks like we might have :)

@zachfeldman
Copy link

@codingjester woah this is a blast from the past. I'm not longer with #contently who was using the gem heavily but you might want to check in with @sanjayginde or @kcurtin on this who are still on the team!

@persocon
Copy link

I just updated to 0.8.3

still getting {"status"=>401, "msg"=>"Not Authorized"} when using source: [array of images]
and getting a big error when using data over source

No such file or directory @ rb_sysopen - ["/Users/persocon/photo-cms/public/images/uploads/img011.jpg","/Users/persocon/photo-cms/public/images/uploads/Messenger_5820543832696890280_13877258035482402.jpg","/Users/persocon/photo-cms/public/images/uploads/Messenger_5820543832696890280_13877258333702839.jpg","/Users/persocon/photo-cms/public/images/uploads/Messenger_5820543832696890280_13877257902081296.jpg"]

@codingjester
Copy link
Author

Awesome for confirming it's still broken @persocon Would you be able to throw me some code on exactly how you're sending your photos? I was able to send photos without a problem using the :data parameter.

@persocon
Copy link

Sure
First I loop to get my CMS uploaded images this way:

images = content.uploads.map { |img| 
    img.file.current_path
  }

client = Tumblr::Client.new

photo = client.photo(current_account.tumblr_url, {:caption => content[:body], :data => images, :format => 'markdown'})

like this :) the result is a array of image paths

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants