Module: Soundcloud

Defined in:
lib/soundcloud.rb,
lib/soundcloud/models/base.rb,
lib/soundcloud/models/user.rb,
lib/soundcloud/models/event.rb,
lib/soundcloud/models/track.rb,
lib/soundcloud/models/comment.rb,
lib/soundcloud/models/playlist.rb

Defined Under Namespace

Modules: Models

Class Method Summary collapse

Class Method Details

.consumer(consumer_token, consumer_secret, site = 'http://api.soundcloud.com') ⇒ Object

Will create an OAuth Consumer for you.

You have to register your application on soundcloud.com to get a consumer token and secret.

Optionally you can specify another provider site (i.e. api.sandbox-soundcloud.com)

Default provider site is api.soundcloud.com



21
22
23
24
25
26
27
28
29
# File 'lib/soundcloud.rb', line 21

def self.consumer(consumer_token,consumer_secret, site = 'http://api.soundcloud.com')
  return OAuth::Consumer.new(consumer_token, consumer_secret, {
      :site               => site,
      :request_token_path => "/oauth/request_token",
      :access_token_path  => "/oauth/access_token",
      :authorize_path     => "/oauth/authorize",
      :scheme             => :query_string
    })    
end

.register(options = {}) ⇒ Object

Will create a soundcloud module containing all the soundcloud models. This module is bound to the given OAuth access token.

Options:

:access_token = your oauth access token
:site = soundcloud api site (i.e. "http://api.sandbox-soundcloud.com", defaults to "http://api.soundcloud.com")

Examples:

# unauthenticated to "http://api.soundcloud.com"  
cl = Soundcloud.register()

# authenticated connection to soundcloud sandbox
cl = Soundcloud.register({:access_token => your_access_token, :site => "http://api.sandbox-soundcloud.com"})


46
47
48
49
# File 'lib/soundcloud.rb', line 46

def self.register(options = {})
  options[:site] = options[:site] || 'http://api.soundcloud.com'
  OAuthActiveResource.register(self.ancestors.first, self.ancestors.first.const_get('Models'), options)
end