Skip to content
October 23, 2011 / zendtutorials

Uploading videos on YouTube using api without zend framework No client library (Elaboration of AuthSub for uploading videos on YouTube using core php php4 Browser based direct upload in corephp php4).

This post has been moved to http://www.codershelpingcoders.com/

140 Comments

Leave a Comment
  1. asif / Oct 28 2011 10:22 am

    please send me the working code…

    • zendtutorials / Oct 30 2011 5:50 pm

      Hello Asif,

      We have mailed you the code for you tube upload.There are few directions in there to use that code.Please install it and use it and let us know in case there is any problem installing it.Do provide your valuable comments.
      Cheers 🙂

  2. zendtutorials / Oct 30 2011 5:49 pm

    Hello Asif,

    We have mailed you the code for you tube upload.There are few directions in there to use that code.Please install it and use it and let us know in case there is any problem installing it.Do provide your valuable comments.
    Cheers 🙂

    • asif / Oct 31 2011 2:51 pm

      thanks i have received that i will check it thnks for your quick response…

  3. dipak / Nov 4 2011 3:39 pm

    I have tried this code, and its working fine with curl and with file control to select the file.
    But I want code for the uploading video without selecting file from the file control, and my dynamically generated file should go to youtube. Still i have not found any code for this direct uploading in core php, without using file control to select file.
    It would be great, if you can provide code to upload dynamic video on my youtube channel.
    Thanks in advance

    • zendtutorials / Nov 5 2011 8:10 pm

      Hello Dipak,
      What do you mean by DYNAMICALLY GENERATED file here?

    • zendtutorials / Nov 5 2011 9:42 pm

      If you want to upload a video which is hosted to your site Then you will have to use VideoEntry object.You will have to use Zend Frame work
      $yt = new Zend_Gdata_YouTube($httpClient);

      // create a new VideoEntry object
      $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();

      // create a new Zend_Gdata_App_MediaFileSource object
      $filesource = $yt->newMediaFileSource(‘file.mov’);
      $filesource->setContentType(‘video/quicktime’);
      // set slug header
      $filesource->setSlug(‘file.mov’);

      // add the filesource to the video entry
      $myVideoEntry->setMediaSource($filesource);

      $myVideoEntry->setVideoTitle(‘My Test Movie’);
      $myVideoEntry->setVideoDescription(‘My Test Movie’);
      // The category must be a valid YouTube category!
      $myVideoEntry->setVideoCategory(‘Autos’);

      // Set keywords. Please note that this must be a comma-separated string
      // and that individual keywords cannot contain whitespace
      $myVideoEntry->SetVideoTags(‘cars, funny’);

      // set some developer tags — this is optional
      // (see Searching by Developer Tags for more details)
      $myVideoEntry->setVideoDeveloperTags(array(‘mydevtag’, ‘anotherdevtag’));

      // set the video’s location — this is also optional
      $yt->registerPackage(‘Zend_Gdata_Geo’);
      $yt->registerPackage(‘Zend_Gdata_Geo_Extension’);
      $where = $yt->newGeoRssWhere();
      $position = $yt->newGmlPos(‘37.0 -122.0’);
      $where->point = $yt->newGmlPoint($position);
      $myVideoEntry->setWhere($where);

      // upload URI for the currently authenticated user
      $uploadUrl = ‘http://uploads.gdata.youtube.com/feeds/api/users/default/uploads’;

      // try to upload the video, catching a Zend_Gdata_App_HttpException,
      // if available, or just a regular Zend_Gdata_App_Exception otherwise
      try {
      $newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, ‘Zend_Gdata_YouTube_VideoEntry’);
      } catch (Zend_Gdata_App_HttpException $httpException) {
      echo $httpException->getRawResponseBody();
      } catch (Zend_Gdata_App_Exception $e) {
      echo $e->getMessage();
      }

    • zendtutorials / Nov 5 2011 9:52 pm

      If you still want to do it without the Zend Framework there is still a way to do it.

      • Pandian / Dec 21 2011 7:48 pm

        hi,
        may i know the codes for without using any framework to upload videos in youtube from an own site..please reply me soon…..my email id is

        jagan.pand@gmail.com

      • Pandian / Dec 21 2011 7:57 pm

        hi

        i want the core php codes in below things……

      • zendtutorials / Dec 22 2011 9:02 pm

        Hello Pandian.

        we have mailed you the script.If you need help in deploying please let us know.

  4. Reece / Nov 26 2011 7:13 pm

    Hi,

    I’ve got a script at the moment without the Zend but I want to have an entry form with the upload that allows me to put in the title and description.

    Will I be able to do that with this script?

    Thanks!

    • zendtutorials / Nov 26 2011 9:44 pm

      Yes Reece..I think you need a form where you can fill out description,tags and other metadata of the video and user using that form would be able to select the file to upload to YouTube.Yes that is possible and this script is the one to do so.

      Let us know if you need any help in implementing it.

      Thanx for commenting.

      Cheers..

      • Reece / Nov 26 2011 11:44 pm

        Hi,

        Yes this sounds great, I’ve been looking for something like this for months now! 😀

        Would you be able to email the script so I can give it a try?

        Thanks
        Reece

  5. zendtutorials / Nov 27 2011 1:13 am

    Your email address please?..

    • Reece / Nov 27 2011 4:27 am

      reece [at] ve3tro.com

      Thanks

      • zendtutorials / Nov 27 2011 11:49 am

        Hello Reece,

        We have mailed you the script.

        Have a look and comment if you need help deploying it.

        Best Of Luck.

  6. Reece / Nov 27 2011 4:54 pm

    Thank you for the script.

    Every time I choose to upload I get the Allow Access page from YouTube. Is there a way I can put in my login details on the script so then it bypasses the Allow Access page?

    What I want this for is to allow many people to use the script to upload videos to my channel without the need to login.

    • zendtutorials / Nov 27 2011 8:07 pm

      Yes Reece,If you have studied the script.Look for AuthSubSessToken.Obtain it once and hardcode the same permanently in $_SESSION[‘AuthSubSessToken’] it will never take you to the Access page again.Only Once it will unless the token is revoked.

      Try it.

      • Alex Lalu / Dec 27 2011 8:37 am

        Please Send me the full code for uploading videos to youtube.Iam not an expert in coding..So please send me the full code for that..Also i need the videos directly upload to my account only..because i want to organize all my site videos under a single channel or user account.Please help me..
        Thanks in Anvance
        Happy NewYear 2012

        My Email ID is friend007u@gmail.com
        Alex Lalu

      • zendtutorials / Dec 27 2011 9:29 pm

        Hello Alex,

        We have mailed you the code.Kindly find the attachment and let us know if you need help in deployment.

    • zendtutorials / Nov 29 2011 9:42 pm

      Hello Reece,

      Hope that helped you.I will not be available for sometime due to some health problems but in case there is something more i can do just leave a comment.But i am sure the last trick had already helped you.

      Enjoy.

  7. suzilala / Dec 1 2011 7:31 am

    im interested..please can u email me the script mizzsuzy@gmail.com

    • zendtutorials / Dec 1 2011 7:46 pm

      Hello Suzy,

      We have mailed you the script.Please check.

      Cheers.

      • suzilala / Dec 2 2011 8:51 am

        hi, can u give me the instruction to guide for develop the script?

      • zendtutorials / Dec 2 2011 9:58 pm

        What you found Difficult Suzilala?Its very easy to deploy that.Tell us where you need help?All you have to do is make a form as in the script and it will work for you…where do you find it difficult?

      • zendtutorials / Dec 3 2011 1:45 pm

        Hello Suziala,

        All you have to do is to make a form which will collect the data about the video such as title tags etc and upload it using cURL and then obtaining a form upload token and posting the video to YouTube.Thats It.

        Do it like that.And let us know where is the problem.

      • zendtutorials / Dec 6 2011 10:01 pm

        Hello Suzi,

        After clicking ACCEPT and when it comes back to you site.You just have to select the video and upload it.

        Thats all.

      • suzilala / Dec 8 2011 6:12 am

        Ok. after i click the ACCEPT, it will back to my site then i upload the video.where BUTTON UPLOAD should go?

      • zendtutorials / Dec 8 2011 9:00 pm

        Yes Suzi.It should upload your video to YouTube.

  8. zendtutorials / Dec 1 2011 8:02 pm

    People if this has helped you.Please care to give it a like.Will take a minute of yours only..
    Thanx :-)..will keep you posted on new techniques or things that i discover.Or you can suggest me too.

    • Reece / Dec 1 2011 8:05 pm

      Thank you for the tutorial, sorry I didn’t get back quicker just been a little busy. I’ve had a look over the script but not completly filled out the details yet.

      I shall have a go tonight to see how it goes. 😀

      Thanks again!

  9. Amaury / Dec 8 2011 12:47 am

    Hello,

    First, thank you so much for this tutorial, it’s the only place on internet where someone try to do that without Zend Framework.

    I pass the 1st step but I have some troubles on the other steps, i’m really interested in this working script if you can.

    Thank you

    (My email is fastcreasite [at] gmail [dot] com )

    • zendtutorials / Dec 8 2011 9:05 pm

      Hello,

      We have mailed you the script.Have a look.

      Cheers.

  10. Paolo / Dec 13 2011 2:18 am

    Please, can you send me the working code?

  11. karaka / Dec 14 2011 4:58 pm

    I want to send to my youtube acount (with user and pass) a video record and hosted in my website. each one of my users will can upload his videos to my youtube acount.

    and i dont want to use Zend Library. Its posible??

    thanks

    • zendtutorials / Dec 14 2011 9:02 pm

      Hello Karaka,

      Do you want a user to able to select the video from his/her system and then upload it to you tube account then yes this tutorial is all about that.If you want to upload a video that is already stored on your server than we will have to see.I think direct upload will work in that case.So what is your case here?.

  12. karaka / Dec 14 2011 9:52 pm

    i dont understand very well. i dont want the users to able to select the video from his/her system and upload. no is this

    my aplication record videos by webcam and i stored in my server (flv file, i think). I give them the option to upload the video from my server to my youtube account when they press a button

    i dont want use zend library, i want AuthSub with my youtube user and upload video from url (my server).

    sorry, my english is underground. thanks

    • zendtutorials / Dec 14 2011 11:21 pm

      Then you will need DIRECT UPLOAD karaka and this tutorial is about browser based uploading.

  13. karaka / Dec 16 2011 2:24 pm

    i cant find code about direct upload. can you help me?

  14. karaka / Dec 19 2011 2:05 pm

    Thanks. i continue to find

  15. Dmitry / Dec 27 2011 1:52 pm

    Please, send me the working code.
    Thank you!

    • zendtutorials / Dec 27 2011 9:26 pm

      Hello Dmitry,

      Whats your email address?

      • Dmitry / Dec 27 2011 9:28 pm

        Hello,
        d-man AT mail.ru

      • zendtutorials / Dec 27 2011 9:31 pm

        we have mailed you the code Dmitry please check.

      • Dmitry / Dec 27 2011 9:44 pm

        Yep, I got it. Thank you! but there is something wrong with curl_.
        Fatal error: Call to undefined function curl_init()

      • Dmitry / Dec 27 2011 9:48 pm

        I don’t have an ability to change server’s configuration. So are there any other functions that can be used instead of curl funcs?

      • zendtutorials / Dec 28 2011 12:05 am

        You can contact your server tech support and ask them to install it..That is all you need.

      • zendtutorials / Dec 27 2011 10:58 pm

        Dmitry you should have libcurl installed else the code wont work.

  16. zendtutorials / Dec 27 2011 9:29 pm

    51 comments and 0 likes 😦

  17. Tejas P Mehta / Jan 3 2012 3:39 pm

    Hello,

    Nice tutorial. I need working code for direct browser based uploading to youtube from my website in core php using curl.

    my id is : tejaspmehta@gmail.com

    Thank you
    Tejas Mehta

    • zendtutorials / Jan 3 2012 8:30 pm

      Hello Tejas,

      We have mailed you the script.Please have a look and let us know if you need help deploying that.
      Also please spare a moment to like this post if this was helpful to you.

      Cheers.

  18. Tejas P Mehta / Jan 4 2012 12:30 pm

    Hello,

    I have received script but i am bit confused how to use it. What my requirement is that if any user come to site and upload video (10 MB) then it should be uploaded to youtube in my predefined account and in return i should get URL of that video (to store in my db)

    Now when i run this script by changing xxx.com to my-site.com it takes me to youtube page and then ask me for access. I clicked on allow access and it took me to my-site.com. I did not get form which you have placed at end of page for uploading video.

    Also you have not mentioned that where to get keys which is in variable $key.

    Thank you
    Tejas Mehta

    • zendtutorials / Jan 4 2012 8:27 pm

      Hello Tejas,

      The key is the developer key you generate from your google dashboard you can find it here.http://code.google.com/apis/base/signup.html and this is elaboration tutorial of the Browser based upload.Means a user does not have to upload the video on your server first.He can directly upload the video to YouTube into your account.You dont really need to host the videos on your site.Which means half of your work is saved.Also you have to give the path of this script in your next url like http://www.xxx.com/script.php.But one thing i am not sure you can achieve with this is the storing of URL of video in database this technique doesnt really gives back the URL of the video but gives you a response code of 400 or 200 on successful and failed uploads.This you will have to confirm.
      If i can help in any way please let me know.

      Signing Off
      Cheers.
      🙂

  19. khatri / Jan 13 2012 9:43 pm

    Can u plz send me the code

  20. sohrabhossan / Jan 16 2012 12:50 pm

    Could you please send me the workable code?

    Thanks in advance.

  21. sohrabhossan / Jan 16 2012 12:51 pm

    Could you please send me the workable code?

    aantu69@yahoo.com

    Thanks in advance.

    • zendtutorials / Jan 16 2012 7:55 pm

      Hello Sohrab,

      We have mailed you the code.Please check.

      Thanks for liking.

  22. sohrabhossan / Jan 17 2012 2:25 pm

    Thanks for your quick response. Its unbelievable.

    But one thing, while the page is loading , its redirect to http://support.google.com/accounts/bin/answer.py?hl=en&p=youtube&answer=40039

    and here saying that

    “Unable to access a Google product
    If you’ve been redirected to this page from a particular product, it means that your access to this product has been suspended. Read on for more information……….bla bla bla”

    I am unable to solve this problem.
    If you can help me, I’ll be grateful to you.

    Thanks
    Sohrab
    aantu69@yahoo.com

    • zendtutorials / Jan 18 2012 9:27 pm

      Hello,

      Can you give us the link where you are experiencing this problem?It should not take you to this page instead it should allow you to take to the access page where you need to verify the access for the app which will give you the access token and you are ready to upload videos on YouTube.

      Cheers…

      • sohrabhossan / Feb 27 2012 11:47 am

        my video doesnt upload. Please help me.
        http://www.yourekas.com/video

        Thanks.

      • zendtutorials / Feb 27 2012 8:41 pm

        Please leave your email address again

      • sohrabhossan / Feb 27 2012 12:14 pm

        when i click on video upload it doesn’t go anywhere and doesn’t start uploading and also it doesn’t return us the uploaded video id.

      • sohrabhossan / Feb 28 2012 8:57 am

        my email is
        aantu69@yahoo.com

        Thanks.

      • zendtutorials / Feb 28 2012 10:18 pm

        Please place the updated script and let us know

      • sohrabhossan / Feb 29 2012 12:43 pm

        Thanks. many many thanks.
        Its working now.
        I am really happy for your unbelievable response.

        Thanks again.

      • zendtutorials / Mar 1 2012 12:38 am

        You are welcome.

  23. Ahmad / Jan 19 2012 8:17 am

    Hello Zend Tutorial,
    I have downloaded the latest zend-library and have installed it on a RHEL6 (and its latest PHP). Kindly send the codes my way as well at the following email address, please:
    g o r a b i [doNotSpamPlease-AT] g m a i l [doNotSpamPlease-DOT] .com

    • zendtutorials / Jan 19 2012 8:57 pm

      Hello Ahmad,

      This is the code to work without Zend Framework..Not with Zend framework.

  24. Ahmad / Jan 20 2012 10:32 am

    That would still be cool by me! Kindly send it my way.

  25. Ahmad / Jan 21 2012 4:33 am

    Also, are you able to place a full-text-caption (not timed caption) onto the youtube video that you upload, thru this code as well? That would be a PERFECT combo.

    • zendtutorials / Jan 23 2012 7:49 pm

      We have mailed you the code Ahmad.Please have a look.

      • Ahmad / Jan 26 2012 6:17 am

        I’ve saved your script to localhost, generated the developer key at: http://code.google.com/apis/youtube/dashboard
        …and I do get the ‘token’ fine, http://localhost/yt/script.php?token=
        But upload Youtube Metadata (title, category, description, keyword—filled out in the form), goes NO-PLACE. Not sure what I’m missing. Printed your 4-step doc’n as well, I guess the script is stuck at 2 (part a)— use token to get AuthSubSessionToken

      • zendtutorials / Jan 28 2012 1:30 pm

        Uploading the metadata will issue you a GetUploadToken which the mechanism will set in the form for your video upload.If upload meta data is successful you can upload the videos there and you can see your metadata on the video you have uploaded.

  26. qazzz789 / Jan 22 2012 11:31 pm

    Hello, could you please send me the code?

    qazzz789@aim.com

    thanks in advance

    • zendtutorials / Jan 23 2012 7:49 pm

      We have mailed you the code Qazzz Please check.

      • qazzz789 / Jan 23 2012 7:54 pm

        i haven’t received it 😦
        can you try sending it again
        thank you

      • qazzz789 / Jan 23 2012 7:56 pm

        lol i wasnt sure how much time had passed since your post, ill check later today

      • qazzz789 / Jan 24 2012 1:13 am

        thanks you for the code

  27. ahmad / Jan 24 2012 11:05 am

    I got it. Thank you! Trying to decipher and understand it. I like it off the bat, as it is using sessionIDs. My first go at the script did not work. Note: meta-data & its upload, together with video-choice & upload are all appearing on the same page-view (it is a bit confusing). If it was hiding the video-upload, until it had the meta-data values, would have been more of an eye candy (he He).
    Thanks again.

  28. zendtutorials / Jan 24 2012 9:20 pm

    People please be generous in liking the post if it had helped you in any way.

  29. U / Feb 6 2012 12:59 am

    Hi!

    I would very much like to have a look at the code, could you please mail it to nospamkthxlulz@gmail.com?

    Thanks!

    • zendtutorials / Feb 7 2012 8:46 pm

      Hello.
      We have sent you the script.Please check.

  30. Naveed Abbas / Feb 7 2012 12:53 pm

    hi can you please send me this code at my mail address naveed_uop (at the rate of) yahoo (dot) com. please i need this as soon as possible.

    • zendtutorials / Feb 7 2012 8:47 pm

      Hello.
      We have sent you the script.Please check and see.

      • Naveed Abbas / Feb 8 2012 12:17 pm

        thanks.
        But this code is not in working condition. can you please send me the working example.

      • zendtutorials / Feb 8 2012 6:24 pm

        Why do you say that doesnt works?Did you followed the steps?It is the working Code Naveed.

      • Naveed Abbas / Feb 13 2012 11:06 am

        i have included jquery it uploads meta data but when i click on video upload it doesn’t go anywhere and deosn’t start uploading and also it doesn’t return us the uploaded vdeo id.

      • zendtutorials / Feb 13 2012 7:54 pm

        We have mailed you the new script.Please have a look.

      • Naveed Abbas / Feb 15 2012 12:00 pm

        thanks it is ok now

  31. Naveed Abbas / Feb 8 2012 11:40 am

    But this code is not in working condition. can you please send me the working example.

  32. U / Feb 8 2012 6:57 pm

    I can’t it to work either.

    I’ve set $key to my Google Developer Key and set the url to http://www.mydomain.com/script.php.
    I authorize the “application” and then input the meta data and upload it (doesn’t seem like it gets uploaded) and then I choose which file to upload and press upload (doesn’t seem to upload either, since it takes a millisecond).

    • U / Feb 8 2012 6:59 pm

      ^ Should be and set the $nextUrl to http://www.mydomain.com/script.php

      • zendtutorials / Feb 8 2012 7:37 pm

        its 404

      • zendtutorials / Feb 8 2012 8:34 pm

        We mailed you new script.Try it.

      • zendtutorials / Feb 8 2012 9:13 pm

        Can you go down the code and change the ajax call from index.php to script.php

      • U / Feb 8 2012 9:33 pm

        Ah, now it seems to send the meta data atleast, but when uploading the video file it just redirects immediately, no upload.

      • U / Feb 11 2012 4:23 am

        Just want to thank you for your persistance with my problems, but I would be very happy if you could help me out to get this script working, as I mention in the last reply, it seems like the meta data is now being sent to YouTube, but the file does not get uploaded with you press upload, it just reloads the page, what causes this? Thank you in advance.

      • zendtutorials / Feb 11 2012 8:20 pm

        Please send the link again.

      • U / Feb 11 2012 9:07 pm
      • zendtutorials / Feb 11 2012 9:35 pm

        Can you give me access to the server i have to check it.

      • zendtutorials / Feb 11 2012 9:43 pm

        Seems like your ajax call is not perfect here.

      • zendtutorials / Feb 11 2012 11:05 pm

        On Uploading metadata there we get an Upload url and a token there is a mechanism to set it in the form action and token hidden field and i can see you are not getting back the url or token that is why you dont get to upload the videos.

      • U / Feb 11 2012 11:42 pm

        What do you suppose I’ll change?

      • zendtutorials / Feb 13 2012 7:46 pm

        I have to see it in running condition on the server.

      • U / Feb 14 2012 4:16 am

        Where should I mail the login credencials?

      • zendtutorials / Feb 14 2012 8:20 pm

        same as where you got the script from.

      • zendtutorials / Feb 15 2012 10:53 pm

        I have corrected an error on the url you gave me.But there is some issue on the youtube side..I have escalated that will be back to you with a solution.Thanks for your trust and patience.

      • zendtutorials / Feb 25 2012 6:47 pm

        Hello,

        Its working now you can check.

    • zendtutorials / Feb 8 2012 7:20 pm

      Can you give us a URL where we can see it?

  33. wahabkool / Feb 12 2012 4:20 pm

    Hi, can you please send me the code I would like to have a look at it..
    Thanks
    Hassi

    • zendtutorials / Feb 13 2012 7:47 pm

      Please provide Your email address?

      • kool / Feb 13 2012 7:48 pm

        wahabcool[at]gmail[do][com]

      • zendtutorials / Feb 13 2012 9:35 pm

        We have mailed you the script please let us know if you need help in deploying it.

  34. Leo / Feb 21 2012 3:33 am

    Hi, can you send me the code please?
    i really apreciate it, can i implement this code using adobe flash builder ?
    metalor21@gmail.com

    • zendtutorials / Feb 25 2012 6:56 pm

      Hello Leo,

      This is a php based code.I dont know what is adobe flash builder is about.

  35. Radu / Feb 24 2012 10:09 pm

    Could you please email the code? Thank you in advance!

  36. Radu / Feb 27 2012 3:55 pm

    The email address is: radu.maruntelu[at]becmedia.ro

    Thank you!

  37. zendtutorials / Feb 27 2012 8:48 pm

    Please leave your email address again for updated YouTube Script.

    • Radu / Mar 6 2012 10:49 pm

      My email address is radu.maruntelu[at]becmedia.ro

      Please send me the updated script.

      Thanks again!

  38. Luk / Mar 8 2012 4:37 pm

    Hi Can i i received code too: arbacom[at]interia.pl ?

  39. JOHnE / Mar 13 2012 2:50 am

    hi please send the code at my id.

    • JOHnE / Mar 13 2012 2:53 am

      my id : engitj [at] gmail [dot] com

    • JOHnE / Mar 14 2012 6:34 pm

      Thanx admin, awesome work with the script ,though 1 ques can the auth session token be used for future upload ,without having the user to log in youtube ?

      • zendtutorials / Mar 19 2012 2:08 pm

        Sorry For the delayed reply John.If You store the AuthSubSession permanently in your session variable then it wont go to the YouTube Authorization page again.

  40. Kareena / Mar 15 2012 1:11 pm

    Hi

    Please email me the code

  41. Amol Bhosale / Mar 16 2012 12:23 pm

    Hi,

    My email address is amolbhosale123@gmail.com

    Please send me the updated script.

    Thanks,
    Amol

    • zendtutorials / Mar 19 2012 2:10 pm

      Hello Amol,

      Please check your email for the code.

      Regards
      CodersHelpingCoders

Leave a comment