Skip to content

Instantly share code, notes, and snippets.

@ondrejbartas
Created October 13, 2014 21:18
Show Gist options
  • Save ondrejbartas/218a7920c75df883591d to your computer and use it in GitHub Desktop.
Save ondrejbartas/218a7920c75df883591d to your computer and use it in GitHub Desktop.
############
# 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