0
我有一個小應用程序,我在其中使用gdata將視頻上傳到YouTube。每次嘗試時,都會收到以下錯誤信息:「serviceBase:objectFetcher:failedWithStatus:400 data:GData InvalidRequestUriException
缺少或無效的用戶名。」Gdata youtube upload failedWithStatus:400
我試過使用我的YouTube管家,或者我的Gmail管家,沒有工作。任何幫助,將不勝感激。
這裏是代碼: 「無效的請求URI或頭,或不支持非標準參數」
NSString *devKey = DEVELOPER_KEY;
GDataServiceGoogleYouTube *service = [self youTubeService];
[service setYouTubeDeveloperKey:devKey];
NSString *username = @"[email protected]";
NSString *clientID = CLIENT_ID;
NSURL *url = [GDataServiceGoogleYouTube youTubeUploadURLForUserID:username
clientID:clientID];
// load the file data
NSString *videoPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/output.mp4"];
// NSString *path = [[NSBundle mainBundle] pathForResource:@"YouTubeTest" ofType:@"m4v"];
NSData *data = [NSData dataWithContentsOfFile:videoPath];
NSString *filename = [videoPath lastPathComponent];
// gather all the metadata needed for the mediaGroup
NSString *titleStr = [titleTextField text];
GDataMediaTitle *title = [GDataMediaTitle textConstructWithString:titleStr];
NSString *categoryStr = [mCategoryField text];
GDataMediaCategory *category = [GDataMediaCategory mediaCategoryWithString:categoryStr];
[category setScheme:kGDataSchemeYouTubeCategory];
NSString *descStr = [mDescriptionField text];
GDataMediaDescription *desc = [GDataMediaDescription textConstructWithString:descStr];
NSString *keywordsStr = [mKeywordsField text];
GDataMediaKeywords *keywords = [GDataMediaKeywords keywordsWithString:keywordsStr];
BOOL isPrivate = mIsPrivate;
GDataYouTubeMediaGroup *mediaGroup = [GDataYouTubeMediaGroup mediaGroup];
[mediaGroup setMediaTitle:title];
[mediaGroup setMediaDescription:desc];
[mediaGroup addMediaCategory:category];
[mediaGroup setMediaKeywords:keywords];
[mediaGroup setIsPrivate:isPrivate];
NSString *mimeType = [GDataUtilities MIMETypeForFileAtPath:videoPath defaultMIMEType:@"video/mp4"];
// create the upload entry with the mediaGroup and the file data
GDataEntryYouTubeUpload *entry;
NSLog(@"%@", mimeType);
entry = [GDataEntryYouTubeUpload uploadEntryWithMediaGroup:mediaGroup
data:data
MIMEType:mimeType
slug:filename];
SEL progressSel = @selector(ticket:hasDeliveredByteCount:ofTotalByteCount:);
[service setServiceUploadProgressSelector:progressSel];
GDataServiceTicket *ticket;
ticket = [service fetchEntryByInsertingEntry:entry
forFeedURL:url
delegate:self
didFinishSelector:@selector(uploadTicket:finishedWithEntry:error:)];
[self setUploadTicket:ticket];
}
抱歉,延遲...我無法上傳Youtube樣本...同樣的錯誤。 –