【问题标题】:iPhone Upload video to youtube app using GData frameworkiPhone 使用 GData 框架将视频上传到 youtube 应用程序
【发布时间】:2012-04-03 15:45:17
【问题描述】:

我想将视频从我的应用上传到 youtube。为此,我正在使用示例 YoutubeTest。我已经为我的应用设置了开发者密钥和客户端 ID。现在,当尝试使用示例源代码上传视频时,它会显示一个错误:

2012-03-19 10:51:07.947 YouTubeTest[539:f803] serviceBase: objectFetcher: failedWithStatus:400 数据: 2012-03-19 10:51:07.985 YouTubeTest[539:f803] 错误:错误域 = com.google.GDataServiceDomain 代码 = 400“操作无法完成。(com.google.GDataServiceDomain 错误 400。)”用户信息=0x6c49e50 {}

有没有人成功实施 GData 从 iphone 应用程序将视频上​​传到 youtube。谁能给我示例源代码。

【问题讨论】:

  • 如何获取客户端 ID 请给我链接。
  • @MohitGupta 客户端 ID 将是您注册应用程序并获取开发者密钥的应用程序名称。
  • 但它显示错误未链接 Youtube 帐户..如果你有工作代码提供给我..这是我对你的谦虚要求。@coder1010
  • 您是否注册了您的应用并生成了开发者密钥?并给我您的邮件 ID,以便我可以将演示代码发送给您
  • 我的电子邮件是 mohit.gupta7860@rediffmail.com 非常感谢..

标签: iphone youtube-api


【解决方案1】:

是的,当然很多人已经成功地实现了它......嗯,试试这个链接http://urinieto.com/category/google/ 逐行按照说明进行操作。

不确定您是否收到此错误。如果问题仍然存在,请按照上述说明进行操作,我会帮助您。

干杯

【讨论】:

  • 是的,我按照教程中的说明执行了每个步骤。错误仍然存​​在。不知道我错在哪里。即使我尝试将帐户类型从 HOSTED_OR_GOOGLE 更改为 GOOGLE,但仍然失败。不知道该怎么办。
  • 错误代码 400 是一个错误的请求“无效的请求 URI 或标头,或不受支持的非标准参数”。这基本上意味着您的请求格式错误。 code.google.com/apis/gdata/docs/2.0/reference.html#HTTPStatusCodes 链接解释所有错误代码。
  • 您好,您可以使用 YOUTUBE 示例代码将您的视频上传到您的帐户吗..?
  • 没有,只要我使用我的谷歌电子邮件 ID 和密码登录并点击上传,就会出现错误警报框。
  • 当我 NSLogged 我的帖子字符串时,我发现电子邮件 ID 中的字符 @ 打印为 %40。这是问题吗?这是我的帖子字符串:POST STRING--Email=chxxxx.agxxx%40gmail.com&Passwd=chhxxxxxx&source=com.yourcompany.YouTubeTest-1.0&service=youtube&accountType=HOSTED_OR_GOOGLE
【解决方案2】:

我在使用 YouTubeTest 应用时遇到了同样的问题。这是请求的代码:

(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];

}

【讨论】:

    【解决方案3】:

    解决了我的问题。您的情况下的错误信息是不够的。但是,如果您从服务器打印出 HTTPURLResponse,这将有助于发现错误。在我的情况下,关键字长度太长。

    【讨论】:

      【解决方案4】:

      我遇到了同样的错误。但我确实通过反复试验找到了解决方案:)

      实际上就像 Youtube 自己所说的那样

      您不再需要提供 Client_Id。请删除它。

      但实际问题在于登录凭据。当我以“xyz@gmail.com”身份登录时,API 返回错误响应。当我只提供没有域“xyz”的用户名时,它就开始工作了。

      希望这会有所帮助!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-07-28
        • 2012-11-20
        • 1970-01-01
        • 2012-08-03
        • 2011-12-13
        • 2012-03-31
        • 2012-06-03
        相关资源
        最近更新 更多