serviceBase:<GDataServiceGoogleYouTube: 0x783de30> objectFetcher:<GDataHTTPUploadFetcher: 0x78520b0> failedWithStatus:400 data:<errors xmlns='http://schemas.google.com/g/2005'><error><domain>GData</domain><code>InvalidRequestUriException</code><internalReason>Missing or invalid username.</internalReason></error></errors>
- (IBAction)uploadClicked:(id)sender
- (GDataServiceGoogleYouTube *)youTubeService
{
static GDataServiceGoogleYouTube* service = nil;
if (!service)
{ service = [[GDataServiceGoogleYouTube alloc] init];
[service setShouldCacheDatedData:YES];
[service setServiceShouldFollowNextLinks:YES];
[service setIsServiceRetryEnabled:YES];
}
NSString *username = [kYoutubeUsername retain];
NSCharacterSet *whitespace = [NSCharacterSet whitespaceAndNewlineCharacterSet];
kYoutubeUsername = [username stringByTrimmingCharactersInSet:whitespace];
if ([kYoutubeUsername rangeOfString:@"@"].location == NSNotFound)
{ kYoutubeUsername = [kYoutubeUsername stringByAppendingString:@"@gmail.com"]; }
if (([kYoutubeUsername length] > 0) && ([kYoutubePassword length] > 0))
{ [service setUserCredentialsWithUsername:[kYoutubeUsername retain] password:[kYoutubePassword retain]]; }
else
{ [service setUserCredentialsWithUsername:nil password:nil]; }
[service setYouTubeDeveloperKey:DEVELOPER_KEY];
return service;
}
And the (NSString *) objects "kYoutubeUsername" and "kYoutubePassword" are set as:
kYoutubeUsername = mUsernameField.text;
kYoutubePassword = mPasswordField.text;
This is done in another method, prior to showing the UITextFields with required GDataYouTubeMediaGroup fields such as: Title, Description, Category, Keywords, and if it's a private entry or not.
This is the actual definition of "kYoutubeUsername" and "kYoutubePassword":
@interface YoutubeController : UIViewController
{
/*.
. Other definitions
.*/
NSString *kYoutubeUsername;
NSString *kYoutubePassword;
}
- (IBAction)uploadClicked:(id)sender
{
[mUploadProgressView setHidden:NO];
GDataServiceGoogleYouTube *service = [self youTubeService];
[service setYouTubeDeveloperKey:DEVELOPER_KEY];
NSString *username = kYoutubeUsername;
NSURL *url = [GDataServiceGoogleYouTube youTubeUploadURLForUserID:username];
// load the file data
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"100_1142" ofType:@"mov"];
NSData *data = [NSData dataWithContentsOfFile:filePath];
NSString *filename = [filePath lastPathComponent];
// gather all the metadata needed for the mediaGroup
NSString *titleStr = mTitleField.text;
GDataMediaTitle *title = [GDataMediaTitle textConstructWithString:titleStr];
GDataMediaCategory *category = [GDataMediaCategory mediaCategoryWithString:@"Entertainment"];
[category setScheme:kGDataSchemeYouTubeCategory];
NSString *descStr = mDescriptionField.text;
GDataMediaDescription *desc = [GDataMediaDescription textConstructWithString:descStr];
NSString *keywordsStr = mKeywordsField.text;
GDataMediaKeywords *keywords = [GDataMediaKeywords keywordsWithString:keywordsStr];
BOOL isPrivate = ([mPrivateSwitch state] == YES);
GDataYouTubeMediaGroup *mediaGroup = [GDataYouTubeMediaGroup mediaGroup];
[mediaGroup setMediaTitle:title];
[mediaGroup setMediaDescription:desc];
[mediaGroup addMediaCategory:category];
[mediaGroup setMediaKeywords:keywords];
[mediaGroup setIsPrivate:isPrivate];
NSString *mimeType = [GDataUtilities MIMETypeForFileAtPath:filePath
defaultMIMEType:@"video/mov"];
// create the upload entry with the mediaGroup and the file data
GDataEntryYouTubeUpload *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];
[self updateUI];
}
Hi everyone,I'm writing a small iOS App that should upload a video to a YouTube user's account.
I've used the YouTube desktop example and adapted it to the iOS available objects.The app actually compiles and behaves properly. However when I get to the point of UPLOADING the video, it throws me the same error over and over again:serviceBase:<GDataServiceGoogleYouTube: 0x783de30> objectFetcher:<GDataHTTPUploadFetcher: 0x78520b0> failedWithStatus:400 data:<errors xmlns='http://schemas.google.com/g/2005'><error><domain>GData</domain><code>InvalidRequestUriException</code><internalReason>Missing or invalid username.</internalReason></error></errors>