-
-
Save wmoore/952648 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open-uri' | |
require 'net/http' | |
require 'openssl' | |
default_params = {"api" => "v1", "appid" => "iphone1_1", "apiPolicy" => "app1_1", "apiKey" => "2wex6aeu6a8q9e49k7sfvufd6rhh0n", "locale" => "en_US", "timestamp" => Time.now.to_i, "q" => "Tomorrow Never Dies"} | |
param_array = [] | |
default_params.each_pair{|key, value| param_array << "#{key}=#{URI.escape(value.to_s)}" } | |
uri = URI::HTTP.build(:scheme => 'https', :host => "app.imdb.com", :path => "/find", :query => param_array.join("&")) | |
# var unsignedUrl = apiUrl + $.param(params); | |
# params.sig = params.sig + '-' + Crypto.HMAC(Crypto.SHA1, unsignedUrl, apiKey); | |
# | |
# var signedUrl = apiUrl + $.param(params); | |
sig = "app1-#{OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new('sha1'), default_params["apiKey"], uri.to_s)}" | |
param_array << "sig=#{sig}" | |
puts param_array.inspect | |
uri = URI::HTTP.build(:scheme => 'https', :host => "app.imdb.com", :path => "/find", :query => param_array.join("&")) | |
puts uri.to_s | |
puts `curl "#{uri.to_s}"` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment