我試圖在應用程序中使用超級基本Soundcloud功能來使用其UI上傳單個.wav文件。我跟着他們的嚮導,我並沒有真的需要裸露的骨頭份額菜單以外的任何東西,所以我認爲這個代碼將工作:SoundCloud API iOS無法上傳帶有HTTP 422錯誤的音頻
NSURL *trackURL = [[NSURL alloc] initWithString:[docsDir stringByAppendingPathComponent:fileToShare]];
SCShareViewController *shareViewController;
shareViewController = [SCShareViewController shareViewControllerWithFileURL:trackURL
completionHandler:^(NSDictionary *trackInfo, NSError *error){
if (SC_CANCELED(error)) {
NSLog(@"Canceled!");
} else if (error) {
NSLog(@"Ooops, something went wrong: %@", [error localizedDescription
]);
} else {
// If you want to do something with the uploaded
// track this is the right place for that.
NSLog(@"Uploaded track: %@", trackInfo);
}
}];
// If your app is a registered foursquare app, you can set the client id and secret.
// The user will then see a place picker where a location can be selected.
// If you don't set them, the user sees a plain plain text filed for the place.
[shareViewController setFoursquareClientID:@"<foursquare client id>"
clientSecret:@"<foursquare client secret>"];
// We can preset the title ...
[shareViewController setTitle:@"Funny sounds"];
// ... and other options like the private flag.
[shareViewController setPrivate:NO];
// Now present the share view controller.
[self presentModalViewController:shareViewController animated:YES];
[trackURL release];
不過,我得到一個HTTP 422錯誤這個出現在我的調試控制檯:
2016-02-29 11:04:47.129 synthQ[801:443840] parameters: {
"track[asset_data]" = "/var/mobile/Containers/Data/Application/EE58E5CA-B30C-44EB-B207-EB3368263319/Documents/bb.wav";
"track[downloadable]" = 1;
"track[post_to][]" = "";
"track[sharing]" = public;
"track[tag_list]" = "\"soundcloud:source=synthQ\"";
"track[title]" = "Funny sounds";
"track[track_type]" = recording;
}
2016-02-29 11:04:47.164 synthQ[801:444011] -[NXOAuth2PostBodyStream open] Stream has been reopened after close
2016-02-29 11:04:47.373 synthQ[801:443840] Upload failed with error: HTTP Error: 422 Error Domain=NXOAuth2HTTPErrorDomain Code=422 "HTTP Error: 422" UserInfo={NSLocalizedDescription=HTTP Error: 422}
有沒有人有任何想法這裏可能會出錯?
謝謝!
這是否意味着我錯誤地引用了該文件?這些文件位於應用程序的「文檔」文件夾中(例如「track [asset_data]」=「/var/mobile/Containers/Data/Application/EE58E5CA-B30C-44EB-B207-EB3368263319/Documents/bb.wav」; is什麼是作爲軌道文件發送)。所以我不確定我做錯了什麼? – chmod