2012-04-06 57 views
1

我有一個iOS應用通過gdata和YouTube API獲取用戶的所有視頻。我的問題伴隨着私人視頻,我需要這樣做才能在視頻被選定時公開私人視頻。如何使用Gdata for iOS更改視頻從私有公開YouTube API應用

由於某種原因,每當我嘗試製作視頻時,我都無法對其進行編輯,因爲YouTube API返回的條目的editLink爲空。

這裏是我的代碼,有人能告訴我什麼,我做錯了或者我能做些什麼,以使更改:

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 :))"); 
    } 
} 

回答

0

我包含在下面所示的請求/響應開發人員密鑰和接收到的EDITLINK響應。您必須將使用oauth操場的協議與您的客戶端語言聯繫起來。

https://groups.google.com/group/youtube-api-gdata/browse_thread/thread/346eb7c8bdd6c3ae

你驗證您的要求嗎?

你指定v = 2嗎?

您是否在查詢中包含開發人員密鑰?

如果您的身份驗證並在查詢字符串中使用v = 2,那麼您應該獲得編輯鏈接。

https://code.google.com/oauthplayground/瞭解的開發工具,其中i由下面的請求指定將包含只是鏈路局部GDATA領域[@的rel =「編輯」]標籤:

GET /feeds/api/users/default/uploads/7dtC4kS3x08?v=2&fields=link%5B%40rel%3D%22edit%22%5D&alt=json&key=${YT-devKeyValue} HTTP/1.1 
Host: gdata.youtube.com 
Authorization: OAuth ya29.AHES6ZSqIlhsyFfbzZ7x-PTVR1JiTj1PjPvBbfq7RtKnaJk 

響應包括在所述EDITLINK底部 - 當您將更新發布到api時,應該使用attribute = href的值:

{ 
"version":"1.0", 
"encoding":"UTF-8", 
"entry":{ 
"xmlns":"http://www.w3.org/2005/Atom", 
"xmlns$yt":"http://gdata.youtube.com/schemas/2007", 
"link":[ 
{ 
"rel":"edit", 
"type":"application/atom+xml", 
"href":"https://gdata.youtube.com/feeds/api/users/rowntreerob/uploads/7dtC4kS3x08?v=2" 
} 
] 
} 
} 
相關問題