Created
October 13, 2014 21:18
-
-
Save ondrejbartas/218a7920c75df883591d 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
############ | |
# PLASE FILL | |
############ | |
secret_key = "APPLICATION_SECRET_KEY_INSERT" | |
application = "APPLICATION_KEY_INSERT" | |
instance = "INSTANCE_INSERT" | |
############ | |
# THAN RUM | |
############ | |
require 'openssl' | |
require 'Base64' | |
require 'curb' | |
main_url = "https://openapi.wix.com" | |
base_path = "/v1/contacts" | |
#prepare timestamp | |
timestamp = Time.now.strftime("%FT%H:%M:%S.%L%:z") | |
#put all data for signing | |
out = ["GET", base_path, application, instance, timestamp].join("\n") | |
#create signature | |
signature = Base64.urlsafe_encode64(OpenSSL::HMAC.digest('sha256', secret_key,out)).gsub('=','') | |
# create request | |
http = Curl.get("#{main_url}#{base_path}") do|http| | |
#set all headers | |
http.headers['x-wix-application-id'] = application | |
http.headers['x-wix-instance-id'] = instance | |
http.headers['x-wix-timestamp'] = timestamp | |
http.headers['x-wix-signature'] = signature | |
end | |
#preform request and print output | |
puts http.body_str | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment