我正在尝试使用 GData API 从我的 iPhone 应用程序内部将视频发布到 youtube。这是我正在使用的代码:
GDataServiceGoogleYouTube* service = [self youTubeService];
[service setYouTubeDeveloperKey:youtubeAppKey];
NSString *username = service.username;
NSURL *url = [GDataServiceGoogleYouTube youTubeUploadURLForUserID:username];
NSData *data = [NSData dataWithContentsOfFile:self.videoPath];
NSString *filename = @"My Cool Video";
NSString *titleStr = @"Title";
GDataMediaTitle *mediaTitle = [GDataMediaTitle textConstructWithString:titleStr];
NSString *categoryStr = @"Comedy";
GDataMediaCategory *mediaCategory = [GDataMediaCategory mediaCategoryWithString:categoryStr];
[mediaCategory setScheme:kGDataSchemeYouTubeCategory];
NSString *descStr = @"Description";
GDataMediaDescription *mediaDesc = [GDataMediaDescription textConstructWithString:descStr];
NSString *keywordsStr = @"iOS";
GDataMediaKeywords *mediaKeywords = [GDataMediaKeywords keywordsWithString:keywordsStr];
GDataYouTubeMediaGroup *mediaGroup = [GDataYouTubeMediaGroup mediaGroup];
[mediaGroup setMediaTitle:mediaTitle];
[mediaGroup setMediaDescription:mediaDesc];
[mediaGroup addMediaCategory:mediaCategory];
[mediaGroup setMediaKeywords:mediaKeywords];
[mediaGroup setIsPrivate:isPrivate];
NSString *mimeType = [GDataUtilities MIMETypeForFileAtPath:self.videoPath
defaultMIMEType:@"video/mp4"];
GDataEntryYouTubeUpload *entry = [GDataEntryYouTubeUpload uploadEntryWithMediaGroup:mediaGroup
data:data
MIMEType:mimeType
slug:filename];
GDataServiceTicket *ticket = [service fetchEntryByInsertingEntry:entry
forFeedURL:url
delegate:self
didFinishSelector:@selector(uploadTicket:finishedWithEntry:error:)];
[self setUploadTicket:ticket];
我有这样的回应:
serviceBase: objectFetcher:GTMHTTPUploadFetcher 0x48af0a0 (https://uploads.gdata.youtube.com/resumable/feeds/api/users/myCoolMail@gmail.com/uploads?upload_id=heregoesidiremoved) failedWithStatus:400 data:GDataInvalidRequestUriException
异常消息不可用
我试过谷歌示例代码并得到相同的结果。我使用了设备和模拟器(5.0)。只要从 iPhone 录制,我就尝试过准备视频。我在 google API 部分创建了项目并获得了应用程序密钥。
请帮助我找到问题的解决方案!