Sha256: f7eebe8d38cc4c45a4d5da1fe51c17ce941430197b6ed9d416375ae8f539f1c3

Contents?: true

Size: 1.91 KB

Versions: 1

Compression:

Stored size: 1.91 KB

Contents

# This is a ruby wrapper for the soundcloud API
#
# Author:: Johannes Wagener (johannes@wagener.cc)

require 'rubygems'

gem 'pelle-oauth', '0.3.6'
require 'oauth'

gem 'jwagener-oauth-active-resource'
require 'oauth_active_resource'

module Soundcloud  
   # 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. http://api.sandbox-soundcloud.com)
   #
   # Default provider site is http://api.soundcloud.com
   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"
      })    
  end


  # 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"})
  #
  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
end

require 'soundcloud/models/base'
require 'soundcloud/models/user'
require 'soundcloud/models/comment'
require 'soundcloud/models/event'
require 'soundcloud/models/playlist'
require 'soundcloud/models/track'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
soundcloud-ruby-api-wrapper-0.4.1 lib/soundcloud.rb