Youtube api 无法启动可恢复上载

Youtube api 无法启动可恢复上载,youtube-api,google-api-php-client,Youtube Api,Google Api Php Client,Api版本0.6.2 我是这样回答的: 我要走了 Failed to start the resumable upload 500 Internal Server Error - Google_Exception 堆栈跟踪 in /home/darko/NetBeansProjects/shekortet/vendor/google/google-api-php-client/src/service/Google_MediaFileUpload.php at line 260 -+

Api版本0.6.2

我是这样回答的:

我要走了

Failed to start the resumable upload
500 Internal Server Error - Google_Exception 
堆栈跟踪

in /home/darko/NetBeansProjects/shekortet/vendor/google/google-api-php-client/src/service/Google_MediaFileUpload.php at line 260  -+
        if (200 == $code && true == $location) {
          return $location;
        }
        throw new Google_Exception("Failed to start the resumable upload");
      }
    } 

at Google_MediaFileUpload ->getResumeUri (object(Google_HttpRequest))
in /home/darko/NetBeansProjects/shekortet/vendor/google/google-api-php-client/src/service/Google_MediaFileUpload.php at line 214  -+
      public function nextChunk(Google_HttpRequest $req, $chunk=false) {
        if (false == $this->resumeUri) {
          $this->resumeUri = $this->getResumeUri($req);
        }
        if (false == $chunk) {

at Google_MediaFileUpload ->nextChunk (object(Google_HttpRequest), '')
in /home/darko/NetBeansProjects/shekortet/src/Dalu/MediaBundle/Controller/EncodeController.php at line 284  -+
                    while (!$status && !feof($handle))
                    {
                        $chunk = fread($handle, $chunkSizeBytes);
                        $uploadStatus = $media->nextChunk($result, $chunk);
                        var_dump($uploadStatus);
                    }
in /home/darko/NetBeansProjects/shekortet/vendor/google/google-api-php-client/src/io/Google_REST.php at line 66  -+
            $err .= ": ($code) $body";
          }
          throw new Google_ServiceException($err, $code, null, $decoded['error']['errors']);
        }

        // Only attempt to decode the response, if the response code wasn't (204) 'no content'

at Google_REST ::decodeHttpResponse (object(Google_HttpRequest))
in /home/darko/NetBeansProjects/shekortet/vendor/google/google-api-php-client/src/io/Google_REST.php at line 36  -+
       */
      static public function execute(Google_HttpRequest $req) {
        $httpRequest = Google_Client::$io->makeRequest($req);
        $decodedResponse = self::decodeHttpResponse($httpRequest);
        $ret = isset($decodedResponse['data'])
            ? $decodedResponse['data'] : $decodedResponse;
        return $ret;

at Google_REST ::execute (object(Google_HttpRequest))
in /home/darko/NetBeansProjects/shekortet/vendor/google/google-api-php-client/src/service/Google_ServiceResource.php at line 186  -+
          return $httpRequest;
        }
        return Google_REST::execute($httpRequest);
      }
      public  function useObjects() {

at Google_ServiceResource ->__call ('insert', array(array('part' => 'status,snippet', 'postBody' => object(Google_Video), 'mediaUpload' => object(Google_MediaFileUpload))))
in /home/darko/NetBeansProjects/shekortet/vendor/google/google-api-php-client/src/contrib/Google_YouTubeService.php at line 789  -+
        public function insert($part, Google_Video $postBody, $optParams = array()) {
          $params = array('part' => $part, 'postBody' => $postBody);
          $params = array_merge($params, $optParams);
          $data = $this->__call('insert', array($params));
          if ($this->useObjects()) {
            return new Google_Video($data);
          } else {

at Google_VideosServiceResource ->insert ('status,snippet', object(Google_Video), array('mediaUpload' => object(Google_MediaFileUpload)))
in /home/darko/NetBeansProjects/shekortet/src/Dalu/MediaBundle/Controller/EncodeController.php at line 277  -+
                    $media = new \Google_MediaFileUpload('video/x-matroska', null, false, $chunkSizeBytes);
                    $media->setFileSize(filesize($filename));
                    $result = $youtube->videos->insert("status,snippet", $gvideo, ['mediaUpload' => $media]);
                    $status = false;
                    $handle = fopen($filename, "rb");
当试图发布一个不可恢复的上传时,我收到了一个400错误的请求

错误消息

Error calling POST https://www.googleapis.com/youtube/v3/videos?part=status%2Csnippet&key=replacedkeystring: (400) Bad Request 
堆栈跟踪

in /home/darko/NetBeansProjects/shekortet/vendor/google/google-api-php-client/src/service/Google_MediaFileUpload.php at line 260  -+
        if (200 == $code && true == $location) {
          return $location;
        }
        throw new Google_Exception("Failed to start the resumable upload");
      }
    } 

at Google_MediaFileUpload ->getResumeUri (object(Google_HttpRequest))
in /home/darko/NetBeansProjects/shekortet/vendor/google/google-api-php-client/src/service/Google_MediaFileUpload.php at line 214  -+
      public function nextChunk(Google_HttpRequest $req, $chunk=false) {
        if (false == $this->resumeUri) {
          $this->resumeUri = $this->getResumeUri($req);
        }
        if (false == $chunk) {

at Google_MediaFileUpload ->nextChunk (object(Google_HttpRequest), '')
in /home/darko/NetBeansProjects/shekortet/src/Dalu/MediaBundle/Controller/EncodeController.php at line 284  -+
                    while (!$status && !feof($handle))
                    {
                        $chunk = fread($handle, $chunkSizeBytes);
                        $uploadStatus = $media->nextChunk($result, $chunk);
                        var_dump($uploadStatus);
                    }
in /home/darko/NetBeansProjects/shekortet/vendor/google/google-api-php-client/src/io/Google_REST.php at line 66  -+
            $err .= ": ($code) $body";
          }
          throw new Google_ServiceException($err, $code, null, $decoded['error']['errors']);
        }

        // Only attempt to decode the response, if the response code wasn't (204) 'no content'

at Google_REST ::decodeHttpResponse (object(Google_HttpRequest))
in /home/darko/NetBeansProjects/shekortet/vendor/google/google-api-php-client/src/io/Google_REST.php at line 36  -+
       */
      static public function execute(Google_HttpRequest $req) {
        $httpRequest = Google_Client::$io->makeRequest($req);
        $decodedResponse = self::decodeHttpResponse($httpRequest);
        $ret = isset($decodedResponse['data'])
            ? $decodedResponse['data'] : $decodedResponse;
        return $ret;

at Google_REST ::execute (object(Google_HttpRequest))
in /home/darko/NetBeansProjects/shekortet/vendor/google/google-api-php-client/src/service/Google_ServiceResource.php at line 186  -+
          return $httpRequest;
        }
        return Google_REST::execute($httpRequest);
      }
      public  function useObjects() {

at Google_ServiceResource ->__call ('insert', array(array('part' => 'status,snippet', 'postBody' => object(Google_Video), 'mediaUpload' => object(Google_MediaFileUpload))))
in /home/darko/NetBeansProjects/shekortet/vendor/google/google-api-php-client/src/contrib/Google_YouTubeService.php at line 789  -+
        public function insert($part, Google_Video $postBody, $optParams = array()) {
          $params = array('part' => $part, 'postBody' => $postBody);
          $params = array_merge($params, $optParams);
          $data = $this->__call('insert', array($params));
          if ($this->useObjects()) {
            return new Google_Video($data);
          } else {

at Google_VideosServiceResource ->insert ('status,snippet', object(Google_Video), array('mediaUpload' => object(Google_MediaFileUpload)))
in /home/darko/NetBeansProjects/shekortet/src/Dalu/MediaBundle/Controller/EncodeController.php at line 277  -+
                    $media = new \Google_MediaFileUpload('video/x-matroska', null, false, $chunkSizeBytes);
                    $media->setFileSize(filesize($filename));
                    $result = $youtube->videos->insert("status,snippet", $gvideo, ['mediaUpload' => $media]);
                    $status = false;
                    $handle = fopen($filename, "rb");
我几个小时前已经认证了。我看到令牌的生存期是3600(1h)。 这也是在本地完成的 这可能是原因还是什么原因


感谢您的帮助。

在Google_REST.php中进行var_转储后,我得到了
string(257){“error”:{“errors”:[{“domain”:“youtube.video”,“reason”:“invalidCategoryId”,“message”:“坏请求”,“locationType”:“other”,“location”:“body.snippet.categoryId”}],“code”:400,“message”:“坏请求”}
和记录
$gsnippet->setCategoryId('Entertainment')没有数值。因此,我将尝试设置22,如示例所示,无论这意味着什么,问题都会得到回答。数字CategoryId完成了这项工作。我会回答我自己的问题并发布一个categoryid到名称映射的列表,但Stackoverflow歧视新用户;)