schilly Posted September 8, 2010 Share Posted September 8, 2010 Has anyone had any success doing this? I'm not sure if I should try to write this myself or use some kind of framework. I found the Zend Gdata framework (http://framework.zend.com/manual/en/zend.gdata.html) and tried it out but I kept getting error: Warning: include_once() [function.include]: Failed opening '1' for inclusion (include_path='.:/usr/share/pear') I'm assuming it needs to find PEAR which I don't have installed but no where in the Zend docs does it say that it requires PEAR so I'm a little confused. I've never used any of the Zend frameworks so I have no idea if it needs PEAR or not. Anyone have any other methods for doing this? Thx. Quote Link to comment Share on other sites More sharing options...
schilly Posted September 8, 2010 Author Share Posted September 8, 2010 Ok might have figured out my include issue so I'll guess I'll continue trying Zend out. Anyone else done this before? Quote Link to comment Share on other sites More sharing options...
pornophobic Posted September 9, 2010 Share Posted September 9, 2010 I haven't even touched Zend and I refuse to for my own sake. But if you want to get some information, or learn how to do it there is this resource as a good starting point. Quote Link to comment Share on other sites More sharing options...
schilly Posted September 9, 2010 Author Share Posted September 9, 2010 yea already read over the youtube api. they don't have any php examples, just what http headers to send. was hoping to save some time with some example code or pre-built classes. Quote Link to comment Share on other sites More sharing options...
schilly Posted September 16, 2010 Author Share Posted September 16, 2010 Ok got this working finally. Good example here: http://code.google.com/apis/youtube/2.0/developers_guide_php.html Here's my code: <?php error_reporting(E_ALL); //include Zend Gdata Libs require_once("Zend/Gdata/ClientLogin.php"); require_once("Zend/Gdata/HttpClient.php"); require_once("Zend/Gdata/YouTube.php"); require_once("Zend/Gdata/App/MediaFileSource.php"); require_once("Zend/Gdata/App/HttpException.php"); require_once('Zend/Uri/Http.php'); //yt account info $yt_user = 'username or gmail address'; $yt_pw = 'pw'; $yt_source = 'name for your application'; //yt dev key $yt_api_key = 'api-key'; //login in to YT $authenticationURL= 'https://www.google.com/youtube/accounts/ClientLogin'; $httpClient = Zend_Gdata_ClientLogin::getHttpClient( $username = $yt_user, $password = $yt_pw, $service = 'youtube', $client = null, $source = $yt_source, // a short string identifying your application $loginToken = null, $loginCaptcha = null, $authenticationURL); $yt = new Zend_Gdata_YouTube($httpClient, $yt_source, NULL, $yt_api_key); $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry(); $filesource = $yt->newMediaFileSource('absolute/path/to/video'); $filesource->setContentType('video/quicktime'); $filesource->setSlug('mytestmovie.mov'); $myVideoEntry->setMediaSource($filesource); $myVideoEntry->setVideoTitle('My Test Movie'); $myVideoEntry->setVideoDescription('My Test Movie'); // Note that category must be a valid YouTube category ! $myVideoEntry->setVideoCategory('Comedy'); // Set keywords, note that this must be a comma separated string // and that each keyword cannot contain whitespace $myVideoEntry->SetVideoTags('cars, funny'); // Upload URI for the currently authenticated user $uploadUrl = "http://uploads.gdata.youtube.com/feeds/users/$yt_user/uploads"; // Try to upload the video, catching a Zend_Gdata_App_HttpException // if availableor just a regular Zend_Gdata_App_Exception 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(); } echo "<pre>" . var_dump($newEntry) . "</pre>"; echo 'end'; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.