我有一个 iOS 应用程序,它通过 gdata 和 YouTube API 从用户那里获取所有视频。我的问题来自私人视频,我需要制作它以便在选择视频时公开私人视频。
出于某种原因,每当我尝试公开视频时,我都无法对其进行编辑,因为editLink
YouTube API 返回的条目为空。
这是我的代码,有人可以告诉我我做错了什么或者我可以做些什么来做出改变:
GDataEntryBase *entry = [[feed entries] objectAtIndex:selectedRow];
[[(GDataEntryYouTubeVideo *)entry mediaGroup] setIsPrivate:NO];
//GDataEntryYouTubeUpload *uploadEntry =
//[GDataEntryYouTubeUpload uploadEntryWithMediaGroup:mediaGroup
//fileHandle:nil MIMEType:@"video/mp4" slug:[[entry title]
//stringValue]];
GDataServiceTicket *ticket;
GDataServiceGoogleYouTube *service = [self youTubeService];
NSString *str = [entry canEdit] ? @"YES" : @"NO";
NSLog(@"Can edit %@", str);
NSLog(@"Edit URL %@", [[entry editLink] URL] );
// NSURL *url = [GDataServiceGoogleYouTube
//youTubeUploadURLForUserID:kGDataServiceDefaultUser];
ticket = [service fetchEntryByUpdatingEntry:entry
forEntryURL:[[entry editLink] URL] delegate:self
didFinishSelector:@selector(uploadTicket:finishedWithEntry:error:)];
// ticket = [service fetchEntryByUpdatingEntry:entry
//delegate:self didFinishSelector:@selector(uploadTicket:finishedWithEntry:error:)];
NSLog(@"Ticket = %@", ticket);
}
}
- (void)uploadTicket:(GDataServiceTicket *)ticket
finishedWithEntry:(GDataEntryYouTubeVideo *)videoEntry error:(NSError
*)error {
NSLog(@"Finished...");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Upload
failed" message:[NSString stringWithFormat:@"Upload failed: %@",
error] delegate:self cancelButtonTitle:@"Cancel"
otherButtonTitles:nil, nil];
if (error != nil) {
NSLog(@"Errors: %@", error);
[alert show];
} else {
NSLog(@"NO ERRORS :))");
}
}