在VB.net中创建一个SoundCloud桌面客户端时遇到了麻烦:我根本不喜欢和跟踪不同。
登录,播放音乐,获取喜欢,...都完美无缺,但喜欢曲目会给我一个404(找不到文件)错误。
这是我正在使用的代码:
Dim request As WebRequest = WebRequest.Create("https://api.soundcloud.com/me/favorites" & "?client_id=" & Soundcloud.client_ID & "&oauth_token=" & _Token)
request.Method = "PUT"
Dim postData As String = Track.id
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
request.ContentType = "application/x-www-form-urlencoded"
request.ContentLength = byteArray.Length
Dim dataStream As Stream = request.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()
Dim response As WebResponse = request.GetResponse()
Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)
dataStream = response.GetResponseStream()
Dim reader As New StreamReader(dataStream)
Dim responseFromServer As String = reader.ReadToEnd()
Console.WriteLine(responseFromServer)
reader.Close()
dataStream.Close()
response.Close()
开发者网站并没有说太多,它只说这个: “GET,PUT,DELETE / users / {id} / favorites / {id}跟踪用户收藏”
任何人都可以提供帮助吗?提前谢谢。
答案 0 :(得分:1)
我用“api.soundcloud.com/me/favorites/”替换了网址; &安培; Track.id& “?client_id =”& Soundcloud.client_ID& “& oauth_token =”& _Token
那不起作用,但是一旦我将PostData设置为String.Empty就行了......不管怎样,谢谢!