API interface to last.fm/
Create auth object:
auth = Marjan::LastFm::Auth.new 'API KEY', 'API SECRET' auth_url = auth.authorize_url
Rdirect user to auth_url. In your callback action:
auth = Marjan::LastFm::Auth.new 'API KEY', 'API SECRET' session = auth.get_session :token => params[:token]
Save your session key for later use. Use it:
auth = Marjan::LastFm::Auth.new 'API KEY', 'API SECRET', session['key'] user = Marjan::LastFm::User.new auth user.get_info
Scrobbling:
Marjan::LastFm::Scrobbler.client_id = 'your client ID' Marjan::LastFm::Scrobbler.client_version = 'your client version' s = Marjan::LastFm::Scrobbler.new auth, 'marik_te_ua' s.handshake! # tell the world what are you listening right now ;) s.now_playing Marjan::LastFm::Scrobbler::Notification.new('Rammstein', 'Link 2,3,4') # save just played track s.submit Marjan::LastFm::Scrobbler::Submission.new('Rammstein', 'Mutter', (Time.now - 3.minutes).utc.to_i, 'P', '270')
Copyright © 2010 Marjan Krekoten <[email protected]>, released under the MIT license