Skip to content

Instantly share code, notes, and snippets.



Created Jan 26, 2016
What would you like to do?
Example of creating a signed image chart URL for
# This is a working example.
require 'json'
require 'openssl'
require 'base64'
require 'cgi'
ENCRYPT_KEY = "dek-d7a46236eda961a6c3c18ffcc6b077ba87d27e9ae85f7842c6d427c265dd5f69d5131308d93332353d4a55a4b1160fcf516515a4a9f0aa50fbf2d7a2e7d0f1c5"
def charturl_url(template_slug, options)
json = options.to_json
sig = Base64.encode64(OpenSSL::HMAC.digest('sha256', ENCRYPT_KEY, json))
"{PROJECT_TOKEN}/#{template_slug}?d=#{CGI.escape json}&s=#{CGI.escape sig}"
# Call our helper
url = charturl_url("weekly-activity",
{options: {data: {columns: [["This Week", 10,12,41,9,14,15,15], ["Last Week", 9,14,21,21,20,3,5]]}}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment