尝试获取用户播放列表中的所有曲目,它可以在Objective-C演示应用中运行,但是当我在Swift中尝试时,它会返回:
iframe
我正在使用此代码:
<SPTPlaylistList: 0x7fca22d72460>: 0-0 of 1 items (Function)
这是正在运行的Objective-C代码:
SPTPlaylistList.playlistsForUserWithSession(session, callback: { (error, object) -> Void in
if error == nil {
var playlists = object as! SPTListPage
println(playlists)
SPTPlaylistSnapshot.playlistWithURI(playlists.items[0].uri, accessToken: session.accessToken, callback: { (error:NSError!, obj) -> Void in
var playl = obj as! SPTPlaylistSnapshot
println(playl.firstTrackPage.tracksForPlayback)
})
}
})
不确定为什么它会在Swift项目中返回[SPTPlaylistList playlistsForUserWithSession:session callback:^(NSError *error, id object) {
SPTListPage *aa = object;
NSLog(@"%@",aa.items);
[SPTPlaylistSnapshot playlistWithURI:[NSURL URLWithString:@"spotify:user:spotifizr:playlist:3bpGFVfycGnhtcEVb95G98"]
accessToken:session.accessToken
callback:^(NSError *error, SPTPlaylistSnapshot *object) {
NSLog(@"tracks on page 1 = %@", [object.firstTrackPage tracksForPlayback]);
}];
}];
而不是所有轨道。
编辑:尝试
(function)
但现在它返回nil,尽管我在播放列表中有50首曲目。
答案 0 :(得分:2)
您需要在请求的范围中包含以下一项或两项,如果它们尚未存在:
SPTAuthPlaylistReadPrivateScope
和$(document).ready(function() {
// The link is an anchor element with icon camera class
// that will be attached with a new ID called wall-image-upload
// which will destroyed after the window is brought up
$( "a.icon.camera" ).click(function(e) {
// Exit the function when wall-image-upload
// id is created to avoid infinite loop
if ($('#wall-image-upload').length!==0) {
return;
}
// Create the ID
e.target.setAttribute("id", "wall-image-upload");
// Create AjaxUpload object to handle the
// image attachment where it looks up link
// with wall-image-upload ID
var uploader = new window.AjaxUpload(
'wall-image-upload',
{ action: 'wall_upload/{{$nickname}}',
name: 'userfile',
onSubmit: function(file,ext) { $('#profile-rotator').show(); },
onComplete: function(file,response) {
addeditortext(response);
$('#profile-rotator').hide();
}
}
);
// Simulate click on the element, this doesn't effect on
// anything unfortunately
$('#wall-image-upload').trigger("click");
// Destroy the id
$('#wall-image-upload').prop("id",null);
});
});
分别允许访问用户的公开和私人播放列表。