我怀疑Soundcloud的某些内容已经发生变化,因为去年我的代码没有被修改并且工作正常。
我明白了:
Error: HTTP status: 422 Unprocessable Entity, Status Code: 422, playlist_struct:{:title=>"Y11 - REVO - Sop", :description=>"Y11 - REVO - Sop newchoir", :tag_list=>"Sop", :tracks=>"219269586", :format=>"json", :oauth_token=>"..."}
我的oauth_token工作正常。
我打电话:
new_playlist = @client.post('/playlists', playlist_struct)
使用https://github.com/soundcloud/soundcloud-ruby定义@client为:
@client = SoundCloud.new({
:client_id => clientId,
:client_secret => clientSecret,
:username => email,
:password => password
})
并且playlist_struct是根据错误消息。
赞赏的想法!
问候,M。
完整代码:
require 'rubygems'
require 'soundcloud'
require 'pp'
require 'logger'
def login
# http://soundcloud.com/you/apps
clientId = '...'
clientSecret = '...'
email = '...'
password = '...'
# register a new client, which will exchange the username, password for an access_token
# NOTE: the SoundCloud API Docs advise not to use the user credentials flow in a web app.
# In any case, never store the password of a user.
@client = SoundCloud.new({
:client_id => clientId,
:client_secret => clientSecret,
:username => email,
:password => password
})
# print logged in username
puts"h1. Logged in as " + @client.get('/me').username
# updating the users profile description
end
login()
playlist_struct = {
:title => "Hello"
}
new_playlist = @client.post('/playlists', playlist_struct)
@log.info ' OK: '+new_playlist.permalink_url
答案 0 :(得分:0)
看起来playlist_struct现在需要包含
播放列表:{ ... }
围绕内容。
由于代码工作了几年,我冒险尝试这是对API的无声改变。