Created
          August 5, 2011 12:55 
        
      - 
      
- 
        Save bwhitman/1127477 to your computer and use it in GitHub Desktop. 
    Create a 7digital authenticated track/stream URL in javascript
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // requires http://oauth.googlecode.com/svn/code/javascript/ | |
| // by Ralph Cowling [email protected] | |
| // 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