我使用的是JavaScript SDK 3.0.0版。我设法连接,获取曲目并上传新曲目。但是,更新跟踪元数据不起作用。例如:
function compareArrays($arr1, $arr2, $diffThreshold) {
# Assumption: both arrays are the same length.
# If this isn't a valid assumption, take the length of the shortest
$length = count($arr1);
$ctr = 0;
for ($i = 0; $i < $length; ++$i) {
if (abs($arr1[i] - $arr2[i]) <= $diffThreshold) {
++$ctr;
}
}
return $ctr / $length;
}
对OPTIONS请求的回应:
SC.put('/tracks/231833159', {
track: {
title: "New Track Title"
}
});
似乎Request URL: https://api.soundcloud.com/tracks/231833159?
Request Method: OPTIONS
Status Code: 401 Unauthorized
调用省略了格式和oauth令牌的参数。
这是新SC API v3.0.0中的错误还是我做错了?
答案 0 :(得分:1)
这是一个在SDK 3.1.0中修复的错误。
https://github.com/soundcloud/soundcloud-javascript/commit/a98734b43c827c445baa4f7d86e2b84204c3dfec
答案 1 :(得分:0)
解决方法强>
您可以手动将oauth_token添加到URL。 hacky,'&amp;'在URL的末尾,是必要的,因为API包装器会附加一个'?'。
SC.put('/tracks/' + track.id + '?format=json&oauth_token=' + oauth_token + '&', {
track: {
title: "New Track Title"
}
});