Access youtube services with php

I am completely new to php. I am trying to create a system to upload videos to YouTube and save their URLs. Another flash application later brings them together. I clean the target so that I can be sure that the library can perform these tasks.

1) download by default channel 2) get a video 3) download a video for offline viewing

I found the zend library that is used with php using googling. But before a big problem. I am using WAMP. I copied the zend library folder to the folder "C: \ wamp \ www \ zend" and changed php.ini here

; Windows: "\ path1; \ path2" include_path = ".; C: \ wamp \ www \ zend \ library; c: \ php \ includes"

feeling unchanged. Therefore, I am trying to test the library with this code.

<?php error_reporting(E_ALL); ini_set('display_errors', 1); set_include_path('C:/wamp/library/zend/library' . PATH_SEPARATOR . get_include_path()); require_once 'zend/library/Zend/Gdata/YouTube.php'; require_once 'zend/library/Zend/Gdata/ClientLogin.php'; require_once 'zend/library/Zend/Loader/Autoloader.php'; $autoloader = Zend_Loader_Autoloader::getInstance(); $authenticationURL= 'https://www.google.com/youtube/accounts/ClientLogin'; $httpClient = Zend_Gdata_ClientLogin::getHttpClient( $username = ' shabab.h.siddique@gmail.com ', $password = '***', $service = 'youtube', $client = null, $source = 'testphp', $loginToken = null, $loginCaptcha = null, $authenticationURL); $developerKey = 'AI3....w'; $applicationId = 'Student Collaborative Video System'; $clientId = 'Student Collaborative Video System'; $yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey); $yt->setMajorProtocolVersion(2); $videoFeed = $yt->getVideoFeed(Zend_Gdata_YouTube::VIDEO_URI); printVideoFeed($videoFeed); var_dump($videoFeed); ?> 

I am currently seeing an error

1 0.0023 375392 {main} () .. \ testphp.php: 0

2 0.0086 560192 require_once ('C: \ wamp \ www \ zend \ library \ Zend \ Gdata \ YouTube.php') .. \ testphp.php: 7

+1
source share
2 answers

Your code worked fine for me, I just had to configure the inclusion path from \zend\library to X:/zend/framework/library , which was where I put it on my computer. Be sure to use the full path to the structure when setting up the include path.

Then I needed to specifically specify the Zend_Gdata files that we will use. Here is the code that worked.

 <?php set_include_path('X:/zend/framework/library' . PATH_SEPARATOR . get_include_path()); // we must manually require these since we didn't set up the autoloader require_once 'Zend/Gdata/YouTube.php'; require_once 'Zend/Gdata/ClientLogin.php'; $authenticationURL= 'https://www.google.com/youtube/accounts/ClientLogin'; $httpClient = Zend_Gdata_ClientLogin::getHttpClient( $username = ' me@myemail.com ', $password = 'mypass', $service = 'youtube', $client = null, $source = 'MySource', // a short string identifying your application $loginToken = null, $loginCaptcha = null, $authenticationURL); $developerKey = 'myprodkey'; $applicationId = 'TestProduct'; $clientId = 'Student Collaborative Video System'; $yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey); $yt->setMajorProtocolVersion(2); $videoFeed = $yt->getVideoFeed(Zend_Gdata_YouTube::VIDEO_URI); //printVideoFeed($videoFeed); var_dump($videoFeed); // worked, printed out a list of videos in my app 
0
source

replace

 require_once 'Zend\Loader.php'; 

with

 require_once 'Zend/Loader/Autoloader.php'; $autoloader = Zend_Loader_Autoloader::getInstance(); 
0
source

All Articles