2

有很多关于如何在 iOS 应用程序中上传视频的 GData YouTube 教程,但我没有找到显示如何评论视频的教程。所以我在参考页面上阅读,只是尝试过等等,但没有找到任何东西!

有谁知道如何使用 GData API 在 iOS 应用程序中评论视频?

谢谢

4

1 回答 1

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 *ss=@"http://gdata.youtube.com/feeds/api/videos/";
                NSString *idd=@"/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
}
于 2013-11-28T06:19:44.637 回答