Skip to content

Instantly share code, notes, and snippets.

@bwhitman
Created August 5, 2011 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bwhitman/1127477 to your computer and use it in GitHub Desktop.
Save bwhitman/1127477 to your computer and use it in GitHub Desktop.
Create a 7digital authenticated track/stream URL in javascript
// requires http://oauth.googlecode.com/svn/code/javascript/
// by Ralph Cowling ralph@gl-ob.com
// get the trackID from song/search playlist/static with &bucket=id:7digital-UK at http://developer.echonest.com/
function sevDig(trackID)
{
var base = "http://media.geo.7digital.com/media/track/stream",
accessor = { consumerSecret: 'your_consumer_secret' },
params = [
['oauth_nonce',OAuth.nonce(11)],
['oauth_timestamp',OAuth.timestamp()],
['oauth_signature_method','HMAC-SHA1'],
['trackId', trackID],
['oauth_consumer_key','your_consumer_key'],
['country','GB'],
['userId','any_random_string_here']
]
var message = {
method: "GET",
action: base,
parameters: params
};
OAuth.SignatureMethod.sign(message, accessor);
var url = base + '?' + OAuth.SignatureMethod.normalizeParameters(params) + "&oauth_signature=" +
OAuth.getParameter(params, "oauth_signature");
return url;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment