【问题标题】:iOS GData YouTube comment on a VideoiOS GData YouTube 对视频的评论
【发布时间】:2012-12-17 05:32:03
【问题描述】:

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

有人知道如何使用 GData API 在 iOS 应用中评论视频吗?

谢谢

【问题讨论】:

    标签: ios youtube comments youtube-api gdata


    【解决方案1】:

    在评论按钮中使用此方法

    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
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-03-08
      • 2012-11-07
      • 2015-09-26
      • 2013-11-21
      • 2015-12-13
      • 2012-03-22
      • 1970-01-01
      • 2013-01-16
      相关资源
      最近更新 更多