upload video to youtube via iphone application ----ServiceForbiddenException
Posted
by
user577670
on Stack Overflow
See other posts from Stack Overflow
or by user577670
Published on 2011-01-16T17:48:27Z
Indexed on
2011/01/16
17:53 UTC
Read the original article
Hit count: 232
Hey,I use GData try to upload my video to youtube, but meet these error:
serviceBase:<GDataServiceGoogleYouTube: 0x2435f0> objectFetcher:<GDataHTTPUploadFetcher: 0x26dca0> failedWithStatus:403 data:<errors xmlns='http://schemas.google.com/g/2005'>
<error>
<domain>GData</domain>
<code>ServiceForbiddenException</code>
<internalReason>Currently authenticated user does not have write access to desrender's videos.</internalReason>
</error>
</errors>
* is my youtube account.
Following is the code:
- (GDataServiceGoogleYouTube *)youTubeService
{
static GDataServiceGoogleYouTube* service = nil;
if (!service) {
service = [[GDataServiceGoogleYouTube alloc] init];
[service setShouldCacheDatedData:YES];
[service setServiceShouldFollowNextLinks:YES];
[service setIsServiceRetryEnabled:YES];
}
// update the username/password each time the service is requested
NSString *username = [mUsernameField text];
NSString *password = [mPasswordField text];
if ([username length] > 0 && [password length] > 0) {
[service setUserCredentialsWithUsername:username
password:password];
} else {
// fetch unauthenticated
[service setUserCredentialsWithUsername:nil
password:nil];
}
NSString *devKey = [mDeveloperKeyField text];
[service setYouTubeDeveloperKey:devKey];
return service;
}
- (IBAction)uploadPressed:(id)sender {
NSString *devKey = [mDeveloperKeyField text];
GDataServiceGoogleYouTube *service = [self youTubeService];
[service setYouTubeDeveloperKey:devKey];
NSString *username = [mUsernameField text];
NSString *clientID = [mClientIDField text];
NSURL *url = [GDataServiceGoogleYouTube youTubeUploadURLForUserID:username
clientID:clientID];
// load the file data
NSString *path = [[NSBundle mainBundle] pathForResource:@"YouTubeTest" ofType:@"m4v"];
NSData *data = [NSData dataWithContentsOfFile:path];
NSString *filename = [path lastPathComponent];
// gather all the metadata needed for the mediaGroup
NSString *titleStr = [mTitleField 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:path
defaultMIMEType:@"video/mp4"];
// create the upload entry with the mediaGroup and the file data
GDataEntryYouTubeUpload *entry;
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];
}
It almost same as GData's YouTubeSample..
Someone help me!!!!
© Stack Overflow or respective owner