2011-10-02 126 views
1

我完全不熟悉php。我正在尝试构建一个系统将视频上传到YouTube并保留其网址。另一个Flash应用程序稍后将它们结合起来我正在清理目标,以便我可以放心,图书馆可以执行这些任务。从php访问YouTube服务

1)在默认通道 2)获得视频网址 3)上传下载视频进行离线观看

我发现这是由谷歌搜索使用PHP Zend库。但面临很多问题。我正在使用WAMP。我将zend库文件夹复制到“C:\ wamp \ www \ zend”并在此处更改了php.ini

; Windows:“\ path1; \ path2” include_path =“。; C:\ wamp \ www \ zend \ library; c:\ php \ includes”

感觉没有变化。所以我想用这段代码来测试这个库。

<?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 = '[email protected]', 
       $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); 

?> 

错误我目前看到的是

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

2 0.0086 560192 require_once(“C:\瓦帕\ WWW \ zend \ library \ Zend \ Gdata \ YouTube.php').. \ testphp.php:7

+0

附加'使用error_reporting(E_ALL); ini_set('display_errors',1);''<?php'标签后面,可能是你有一个错误,但是它被压制了。另外,在你的set_include_path调用中,我认为'''zend \ library''需要''C:/ wamp/www/zend/library' – drew010

+0

编辑后的代码在后面给出。误差是 调用栈 #\t \t时间内存\t \t功能位置 \t 0.0011 374264 \t {主}()\t .. \ testphp.php:0 \t 0.0045 559056 \t require_once(“C:\ wamp \ www \ zend \ library \ Zend \ Gdata \ YouTube.php')\t .. \ testphp.php:7 – shababhsiddique

回答

0

您的代码对我来说工作得很好,我只需将包含路径从\zend\library调整为X:/zend/framework/library,这是我放置它的位置在我的电脑上。确保在设置包含路径时使用框架的完整路径。

然后我需要特别包含我们将要使用的Zend_Gdata文件。这是有用的代码。

<?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 = '[email protected]', 
       $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

我已经关注了你的文章和所有以前的文章。你会看到编辑的代码吗?并找出我是否错过了什么?我仍然有同样的问题。顺便说一下在Windows中完整的地址是C:/ wamp/library/zend/library还是C:\ wamp \ library \ zend \ library? – shababhsiddique

0

取代

require_once 'Zend\Loader.php'; 

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

不工作,我也尝试了通过改变require_once'..'的方法来解决同样的问题 – shababhsiddique