Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用Zend Gdata上传YouTube视频的请求无效_Php_Http_Zend Framework_Gdata - Fatal编程技术网

Php 使用Zend Gdata上传YouTube视频的请求无效

Php 使用Zend Gdata上传YouTube视频的请求无效,php,http,zend-framework,gdata,Php,Http,Zend Framework,Gdata,我有下面的代码,每次尝试执行时都返回HTTP错误400 $file = "/home/.../videos/bigbuckbunny.mp4"; $title = "This is a test"; $category = "Film"; $description = "test"; $keywords = "test, film, big buck"; Zend_Loader::loadClass('Zend_Gdata_ClientLogin

我有下面的代码,每次尝试执行时都返回HTTP错误400

    $file = "/home/.../videos/bigbuckbunny.mp4";
    $title = "This is a test";
    $category = "Film";
    $description = "test";
    $keywords = "test, film, big buck";

    Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
    Zend_Loader::loadClass('Zend_Gdata_YouTube');  
    Zend_Loader::loadClass('Zend_Gdata_App_HttpException');  

    $httpClient = Zend_Gdata_ClientLogin::getHttpClient($this->settings['username'], $this->settings['password'], 'youtube', NULL, 'Test Client');

    $this->youTube = new Zend_Gdata_YouTube($httpClient, 'Test Client', 'Videos Plugin', $this->settings['key']);
    $this->youTube->setMajorProtocolVersion(2);

    $entry = new Zend_Gdata_YouTube_VideoEntry();  

    $fileSource = $this->youTube->newMediaFileSource($file);  
    $fileSource->setContentType(mime_content_type($file));
    $fileSource->setSlug(basename($file));  

    $entry->setMediaSource($fileSource);  

    $entry->setVideoCategory($category);
    $entry->setVideoTitle($title);  
    $entry->setVideoDescription($description);  
    $entry->setVideoTags($keywords);  

    try
    {
        $uploadUrl = 'http://uploads.gdata.youtube.com/feeds/users/default/uploads';
        $newEntry = $this->youTube->insertEntry($entry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');  
    }
    catch(Zend_Gdata_App_HttpException $e)
    {  
        var_dump($e->getResponse());
        return NULL;
    }
我的设置是正确的。例外情况如下:

object(Zend_Http_Response)#362 (5) {
  ["version:protected"]=>
  string(3) "1.1"
  ["code:protected"]=>
  int(400)
  ["message:protected"]=>
  string(11) "Bad Request"
  ["headers:protected"]=>
  array(9) {
    ["Server"]=>
    string(61) "HTTP Upload Server Built on Mar 22 2012 14:54:02 (1332453242)"
    ["Content-type"]=>
    string(24) "text/html; charset=UTF-8"
    ["X-guploader-uploadid"]=>
    string(98) "AEnB2UoljS9KYUftPEhuRV8hVssGvOHcR1mcK0rfhMOGTBkUYSxX29iKpO9vHisG10EYxQE0-rul3rVEbd2YJlFiXCbaGBpUpQ"
    ["Date"]=>
    string(29) "Fri, 23 Mar 2012 18:36:46 GMT"
    ["Pragma"]=>
    string(8) "no-cache"
    ["Expires"]=>
    string(29) "Fri, 01 Jan 1990 00:00:00 GMT"
    ["Cache-control"]=>
    string(35) "no-cache, no-store, must-revalidate"
    ["Content-length"]=>
    string(2) "15"
    ["Connection"]=>
    string(5) "close"
  }
  ["body:protected"]=>
  string(15) "Invalid Request"
}

有人知道吗?我以前让它工作过,现在它似乎不工作了。

结果是我的上传URL错误,应该是:

$uploadUrl = 'http://uploads.gdata.youtube.com/feeds/users/' . $this->settings['feed'] . '/uploads';