Upload Videos to YouTube with iPhone custom App
EDIT: This is an old post, and apparently things have changed quite a bit. Unfortunately I haven’t had the time to update this and I’m not sure what the process to upload videos to YouTube is anymore.
With the 4.0 iOS and its new AVCaptureSession we now have access to video data, so that developers can edit this info and create cool apps such as SketchWiz, Predator Vision or iRetroscope.
However it’s not clear how these videos can be shared through the net. So in this post I’ll explain how we can upload videos to YouTube with a custom app and provide some sample code to test it.
We will need the Google Data API Client for Objective-C, and install it into our application. Here are the steps to do so:
- Download the GData Client for Objective-C from here
- Open the GData project with XCode
- Drag and drop the group GData Source from the GData project into your project (reference it or copy it into your project directory, up to you)
- Optional: In your project delete all groups inside GData Source but YouTube and Commons. This will make the compilation process much faster. You will have to comment the imports in your GData.h
- Add the Security.framework into your frameworks
- In the properties of your target, add the -ObjC to your Other Linker Flags setting
- In the properties of your target, add the /usr/include/libxml2 path to your Header Search Path setting
- Make sure your C Language Dialect is c99 in your target properties
You should now be able to compile the API within your own app.
Next step is to go here to get a Developer Key from Google. Your Developer Key and Client ID are required in order to use the GData API.
Once you have them, take a look at the simple YouTube upload test sample code based on the Mac OSX Example inside the GData Client Objective-C code and add them there in the YouTubeTestViewController.m.
For more information and other type of installations for the API, please read the API documentation.
I hope it helps. Any feedback is welcome as always.
Cheers, Uri. This saved me a load of time and worry.
Thanks man!
Thank u uri. If it is possible to upload video to youtube without developer Key?
Thanks for your comment dinesh. I don’t think it’s possible to upload a video to youtube without a developer key, but I’m not sure about that. In any case, this key is free to obtain.
hey ,
Nice good post. It helped me a lot. One thing for people who are getting some sort of error like “TOO LONG……. ” just check keywords that are set in the example .. make them short..it will work..also use the actual youtube name instead of gmail username..!!!
Thanks
Thanks, I’m glad it helped you. And thanks for this tip!
hi,
i am getting an error at login time…also i have used DEVELOPER_KEY… and i am using youtube user name instead of gmail id…
Error:Error
Domain=com.google.GDataServiceDomain Code=400 “The operation couldn’t be completed.
Amit, I think youtube doesn’t accept the youtube user, just the google one. This post is rather old, and things might have changed a bit. Try it with the google account.
i new to youtube application and not yet uploaded app to google then is it possible to get client id
@Amit
did u find a way around that error ?
This is really useful . Thanks !
Can anyone suggest how I can obtain the posted URL that YouTube assigns when you have successfully uploaded ? I wanted to be able to capture this and then email it if the user wanted to.
Would appreciate any tips anyone has here or code samples.
I’m glad I found this, but I’m having some trouble getting the video to upload. After I enter my details the app doesn’t seem to be doing anything. Does the app store the sample video on the device before it tries to upload? I thought that might be the problem so I tried to get the video on the device myself, but I’ve struggled with that aswell. I’m very new to iOS development, so please bare with me.
hi guys.. when i am using just “google username” i am getting this error (error Error Domain=com.google.GDataServiceDomain Code=403 “The operation couldn’t be completed.)
ans when i am using email address as an username i am getting following error(error Error Domain=com.google.GDataServiceDomain Code=400 “The operation couldn’t be completed.)..
please i am waiting for a solution. please working sample code will be a great help. you can email me (ml_j13@yahoo.co.in )
hi guys..i have put a developer key & my client id but when i am using just “google username” i am getting this error (error Error Domain=com.google.GDataServiceDomain Code=403 “The operation couldn’t be completed.)
ans when i am using email address as an username i am getting following error(error Error Domain=com.google.GDataServiceDomain Code=400 “The operation couldn’t be completed.)..
please i am waiting for a solution. please working sample code will be a great help. you can email me (ml_j13@yahoo.co.in )
Hello Uri,
I have got the same problem as mayur had discuss with you.
Please send me the running sample code.
ankitsabharwal90@gmail.com
I’m sorry, but I haven’t been doing this for a while, so I am not sure where the problem might be. The sample code (http://urinieto.com/iPhone/YouTubeTest.zip) used to work for me.
Good luck, and thanks for reading and commenting!
Hi,
I had the same error
Domain=com.google.GDataServiceDomain Code=400 “The operation couldn’t be completed.
But when i reduce the keywords lenght its working fine
Thanks uri
Hello Uri,
I have tried this in xcode 4.2 with ios5. I have done the required configuration that you have specified above and also tried http://code.google.com/p/gdata-objectivec-client/wiki/BuildingTheLibrary
But when i run the code and try to upload video the app crashes on error
*** Assertion failure in -[GDataServiceBase fetchObjectWithURL:objectClass:objectToPost:ETag:httpMethod:delegate:didFinishSelector:completionHandler:retryInvocationValue:ticket:]
Please help
can we upload Video on youtube channel in background through iphone
it shows 403 error code and You tube account is not linked….
hi i need sample source code to upload video from iphone to Youtube, but i had been this codes from (http://urinieto.com/iPhone/YouTubeTest.zip) and ( dl.dropbox.com/u/45432200/YouTubeVUpload%2030th%20May-2012.zip), but still i need one more example code
hi i need sample source code to upload video from iphone to Youtube, but i had been tried this codes from (http://urinieto.com/iPhone/YouTubeTest.zip) and ( dl.dropbox.com/u/45432200/YouTubeVUpload%2030th%20May-2012.zip), but still i need one more example code
Hi uri, this is more helpful for everyone , i followed all your steps as u said .. , everything is good but after i entered username and password i’m getting error like this ( Domain=com.google.GDataService Domain code=403″ The operation couldn’t be completed)..
I need to integrate this in my app, please tell me any solution or provide any running samples to my mail id ,,, meganathan@bnbinfotech.com ,
Thanks,,,,,,,,,,
or Please give any other sample tutorial website’s URL
Hi,
Thanks for for nice tutorial. I have configured everything as you have mentioned here, but when I enter username and password I get following error.
serviceBase: objectFetcher: failedWithStatus:400 data:GData
InvalidRequestUriExceptionException message unavailableCould you please help me.
I am getting the below error: please help me ..
YouTubeTest[799:707] serviceBase: objectFetcher: failedWithStatus:400 data:GData
InvalidRequestUriExceptionException message unavailableI miss this file GDataOAuthAuthentication
Thanks Uri for your good post
But I also met the same issues with status code 400,401,403..
Finally I could clear all issues one by one. I created a new youtube account for testing this. So i had to create a new channel in youtube, that was my first issue. But the issue was not cleared soon after the channel creation, it took some time, really i dont know why this time delay. All issues cleared when I came back after my lunch.
Next main issue was 403 error, it took around 2 days for me to clear..
(GDataServiceGoogleYouTube*) setUserCredentialsWithUsername:username password:password
In setUserCredentialsWithUsername: the username is the email id of the account with @gmail.com (username@gmail.com)
but for GDataServiceGoogleYouTube youTubeUploadURLForUserID:username
the username doesnot need the @gmail.com (only ‘username’ required)
or else you can directly use
[GDataServiceGoogleYouTube youTubeUploadURLForUserID:kGDataServiceDefaultUser]
instead of the other one
Then use the correct email id (with @gmail.com) and password to upload the video
Thanks
Getting error when building.
Undefined symbols for architecture i386:
“_OBJC_CLASS_$_GDataOAuthAuthentication”, referenced from:
objc-class-ref in GDataOAuthViewControllerTouch.o
“_OBJC_CLASS_$_GDataOAuthSignIn”, referenced from:
objc-class-ref in GDataOAuthViewControllerTouch.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
These are the errors.Can any one help me out of this.