Skip to content

Instantly share code, notes, and snippets.

@kastner
Created January 31, 2013 19:53
Show Gist options
  • Select an option

  • Save kastner/4685844 to your computer and use it in GitHub Desktop.

Select an option

Save kastner/4685844 to your computer and use it in GitHub Desktop.
require 'digest/md5'
key = YOUR_KEY
secret = YOUR_SECRET
params = {"from_date"=>"2013-01-01", "to_date"=>Time.now.strftime("%Y-%m-%d"), "api_key"=> key, "expire"=>Time.now.utc.to_i + 10000}
def pap(params, sep="&"); params.sort.map {|a| a.join("=")}.join(sep);end
url = "https://data.mixpanel.com/api/2.0/export?" + pap(params) + "&sig=#{Digest::MD5.hexdigest(pap(params, nil) + secret)}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment