2013-01-02 112 views
2

關於如何在iOS應用中上傳視頻,有很多GData YouTube教程,但是我沒有找到一個如何評論視頻的視頻。所以我在參考頁面上閱讀,只是嘗試過等,但沒有找到任何東西!iOS GData對視頻的YouTube評論

有誰知道如何評論在iOS應用程序中使用GData API的視頻?

感謝

回答

2

使用此方法在評論按鈕

GDataEntryYouTubeVideo *video = (GDataEntryYouTubeVideo *)arrayData; 
[self addCommentTitle:@"comment" text:commentField.text toVideo:video]; 


- (void)addCommentTitle:(NSString *)commentTitle 
        text:(NSString *)commentContent 
       toVideo:(GDataEntryYouTubeVideo *)entry { 
    GDataComment *commentObj = [entry comment]; 
    GDataFeedLink *feedLink = [commentObj feedLink]; 
    NSURL *feedURL = [feedLink URL]; 
    if (feedURL) { 
     // fetch the comment feed for the video 

     GDataServiceGoogleYouTube *service = [self youTubeService]; 
     [service setYouTubeDeveloperKey:devKey]; 
     [service setAuthToken:[self getRequestToken]]; 
     [service fetchFeedWithURL:feedURL completionHandler:^(GDataServiceTicket *ticket, GDataFeedBase *commentFeed,NSError *error) { 
     if (error == nil) { 
         GDataEntryYouTubeComment *newCommentEntry = [GDataEntryYouTubeComment commentEntry]; 
       [newCommentEntry addContentValueDeclaration]; 
       [newCommentEntry setTitleWithString:commentTitle]; 
       [newCommentEntry setContentWithString:commentContent]; 
       NSString *subString = [videoString substringWithRange: NSMakeRange(0, [videoString rangeOfString: @"?"].location)]; 
       NSString *last=[subString lastPathComponent]; 
       NSString *[email protected]"http://gdata.youtube.com/feeds/api/videos/"; 
       NSString *[email protected]"/comments"; 
       NSString *com=[NSString stringWithFormat:@"%@%@%@",ss,last,idd]; 
       NSURL *postURL = [NSURL URLWithString:com ]; 
       [service fetchEntryByInsertingEntry:newCommentEntry 
               forFeedURL:postURL 
              completionHandler:^(GDataServiceTicket *ticket, GDataEntryBase *entry, NSError *error) { 
               // callback 
               if (error == nil) { 
                NSLog(@"url.: succeeded "); 
               } 
              }]; 
        } 
      }]; 
    } 
} 

獲得認證令牌使用的登錄信息

- (NSString*) getRequestToken { 
// return your auth token as string 
}