Skip to content

Instantly share code, notes, and snippets.

@zeitan
Created January 3, 2014 17:02
Show Gist options
  • Save zeitan/8241685 to your computer and use it in GitHub Desktop.
Save zeitan/8241685 to your computer and use it in GitHub Desktop.
def fetch_data_from_uri(date)
tms = Time.now.utc.strftime('%Y%m%d%H%M%S')
sig = generate_sig(authentication_config['partner_id'], tms, authentication_config['secret_key'])
body = {
method: @uri.path.split("/").last,
params: {
partner_id: authentication_config['partner_id'],
tms: tms,
sig: sig,
date: date.to_s,
timezone: 'GMT',
attribution: 'click',
fields: ['strategy_group', 'site_id', 'destination_url'],
metrics: ['fb_spend_wfees', 'impressions', 'clicks', 'revenue']
}
}
request = Net::HTTP::Post.new(@uri.path)
request.content_type = 'application/json'
request.basic_auth(authentication_config['username'], authentication_config['password'])
request.body = body.to_json
@api.request(request)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment