从iphone app在youtube上传视频 [英] Upload video on youtube from iphone app

查看:1022
本文介绍了从iphone app在youtube上传视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的iphone应用上传YouTube上的视频..
我试过这个 http://urinieto.com/2010/10/upload-videos-to-youtube-with-iphone-custom-app/
但最终我收到错误
Domain = com.google.GDataServiceDomain Code = 400无法完成操作。(com.google.GDataServiceDomain错误400.)UserInfo = 0x4d921f0 {}

I want to upload video on youtube from my iphone app.. I have tried this http://urinieto.com/2010/10/upload-videos-to-youtube-with-iphone-custom-app/ but in the end i am getting error Domain=com.google.GDataServiceDomain Code=400 "The operation couldn’t be completed. (com.google.GDataServiceDomain error 400.)" UserInfo=0x4d921f0 {}

任何人都可以帮助我。
Thanx !!!

Can any one help me. Thanx!!!

我的代码

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


推荐答案

首先,检查YouTube API是否有任何更新到它的GData库,(他们最后改变了我使用它们并打破了我的应用程序)。

First things first, check the YouTube API for any updates to it's GData libraries, (they changed last I used them and broke my app).

http://apiblog.youtube.com/2009/02/youtube-apis-iphone-cool-mobile-apps.html

接下来,查看愚蠢的东西。导入了所有标题,检查了所有标题等等吗?

Next, check for silly stuff. Got all your headers imported, everything checks out, etc?

尝试设置 info.plist 以使用Wi-Fi,我听说过一些新的GData API可能会解释您的400错误,您的应用可能无法ping通YouTube服务器。

Try setting your info.plist to use Wi-Fi, I've heard some of the new GData API's look for that might explain your 400 error, your app might not be pinging the YouTube servers.

这篇关于从iphone app在youtube上传视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆