Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

🐛 Convert all params keys to string #161

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/instagram/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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)
Expand Down Expand Up @@ -71,10 +71,11 @@ 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
digest = OpenSSL::Digest::Digest.new('sha256')
digest = OpenSSL::Digest.new('sha256')
return OpenSSL::HMAC.hexdigest(digest, secret, sig)
end

Expand Down