From 0ec153a457a0fcff67145beef2047b539743a53a Mon Sep 17 00:00:00 2001 From: Omar Ramos Date: Wed, 29 Apr 2015 17:21:31 -0400 Subject: [PATCH 1/2] :bug: Convert all params keys to string When trying to sort a hash of mixed keys (String and Symbols) an exception occurs, "comparison of Array with Array failed". This is due to sort using <=> which which doesn't work when comparing string to symbols. --- lib/instagram/request.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/instagram/request.rb b/lib/instagram/request.rb index 9c5f061f..90fbb3c4 100644 --- a/lib/instagram/request.rb +++ b/lib/instagram/request.rb @@ -71,6 +71,7 @@ def get_insta_fowarded_for(ips, secret) def generate_sig(endpoint, params, secret) sig = endpoint + params = Hash[params.map{ |k, v| [k.to_s, v] }] params.sort.map do |key, val| sig += '|%s=%s' % [key, val] end From 79ec274b6c568c0303025e7c842f174c82bc67e7 Mon Sep 17 00:00:00 2001 From: Leo Correa Date: Mon, 24 Aug 2015 12:43:00 -0400 Subject: [PATCH 2/2] Use OpenSSL::Digest.new instead of deprecated OpenSSL::Digest::Digest --- lib/instagram/request.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/instagram/request.rb b/lib/instagram/request.rb index 90fbb3c4..5e9ffc5a 100644 --- a/lib/instagram/request.rb +++ b/lib/instagram/request.rb @@ -30,7 +30,7 @@ def delete(path, options={}, signature=false, raw=false, unformatted=false, no_r def request(method, path, options, signature=false, raw=false, unformatted=false, no_response_wrapper=false, signed=sign_requests) response = connection(raw).send(method) do |request| path = formatted_path(path) unless unformatted - + if signed == true if client_id != nil sig_options = options.merge({:client_id => client_id}) @@ -41,7 +41,7 @@ def request(method, path, options, signature=false, raw=false, unformatted=false sig = generate_sig("/"+path, sig_options, client_secret) options[:sig] = sig end - + case method when :get, :delete request.url(URI.encode(path), options) @@ -75,7 +75,7 @@ def generate_sig(endpoint, params, secret) params.sort.map do |key, val| sig += '|%s=%s' % [key, val] end - digest = OpenSSL::Digest::Digest.new('sha256') + digest = OpenSSL::Digest.new('sha256') return OpenSSL::HMAC.hexdigest(digest, secret, sig) end