Rails如何使用SoundCloud歌曲获取SoundCloud曲目信息URL
Rails how to get SoundCloud track information using SoundCloud song URL
在我的 rails 项目中,我想使用用户从他的 SoundCloud 帐户或任何 SoundCloud [=15] 提供的歌曲 url 获取 SoundCloud track/song 标题、描述、提供商数据=].
您可以使用 SoundCloud API for this - see section SoundCloud URLs:
If you have a permalink URL to a particular resource, but need more information such as an ID or other property. In these cases, you can use the /resolve endpoint to extract a full representation of the resource.
还有一个例子使用Ruby:
require 'soundcloud'
# create client with your app's credentials
client = Soundcloud.new(:client_id => 'YOUR_CLIENT_ID')
# a permalink to a track
track_url = 'http://soundcloud.com/forss/voca-nomen-tuum'
# resolve track URL into track resource
track = client.get('/resolve', :url => track_url)
# now that we have the track id, we can get a list of comments, for example
client.get("/tracks/#{track.id}/comments").each do |comment|
puts "Someone said: #{comment.body} at #{comment.timestamp}"
end
在我的 rails 项目中,我想使用用户从他的 SoundCloud 帐户或任何 SoundCloud [=15] 提供的歌曲 url 获取 SoundCloud track/song 标题、描述、提供商数据=].
您可以使用 SoundCloud API for this - see section SoundCloud URLs:
If you have a permalink URL to a particular resource, but need more information such as an ID or other property. In these cases, you can use the /resolve endpoint to extract a full representation of the resource.
还有一个例子使用Ruby:
require 'soundcloud'
# create client with your app's credentials
client = Soundcloud.new(:client_id => 'YOUR_CLIENT_ID')
# a permalink to a track
track_url = 'http://soundcloud.com/forss/voca-nomen-tuum'
# resolve track URL into track resource
track = client.get('/resolve', :url => track_url)
# now that we have the track id, we can get a list of comments, for example
client.get("/tracks/#{track.id}/comments").each do |comment|
puts "Someone said: #{comment.body} at #{comment.timestamp}"
end