1

新しいAPIv3を使用してファイルをYouTubeにアップロードしようとしています。これが私がすることです...

public function upload(){

    if(isset($_FILES['userfile'])) {

        $snippet = new Google_VideoSnippet();

        $snippet->setTitle("Test v3");
        $snippet->setDescription("First upload using api v3");
        $snippet->setTags(array("api","v3"));

        $video = new Google_Video();
        $video->setSnippet($snippet);

            $response = $this->googleapi->youtube->videos->insert(
                "status,snippet",
                $video,
                array('data' => $_FILES['userfile']['tmp_name'])
                );

            var_dump($response);

  }else{
    $this->load->view('youtube');
  }
}

io/Google_REST.phpスローするため、応答は空です

70行目の「未定義のインデックス:エラー」

内にあるdecodeHttpResponse()

ただし、の実際の応答からのダンプGoogle_Client::$io->makeRequest()は次を返します...

object(Google_HttpRequest)#31 (10) { ["batchHeaders":"Google_HttpRequest":private]=>  
array(4) { ["Content-Type"]=>  string(16) "application/http" ["Content-Transfer-Encoding"]=>
string(6) "binary" ["MIME-Version"]=>  string(3) "1.0" ["Content-Length"]=>  string(0) "" }
["url":protected]=>  string(197) "https://www.googleapis.com/upload/youtube
/v3/videos?part=status%2Csnippet&uploadType=multipart&
key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" 
["requestMethod":protected]=>  string(4) "POST" ["requestHeaders":protected]=>  
array(3) { ["content-type"]=>  string(37) "multipart/related; boundary=131050532"
["authorization"]=>  string(64) "BearerXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 
["content-length"]=> int(254) } ["postBody":protected]=>  string(254) 
"--131050532 Content-Type: application/json; charset=UTF-8 {"snippet":{"tags": 
["api","v3"],"title":"Test v3","description":"First upload using api v3"}} --131050532  
Content-Type: Content-Transfer-Encoding: base64 c2FtcGxlLm1wNA== --131050532--"  
["userAgent":protected]=>  string(44) "Youtube test app google-api-php-client/0.6.0"  
["responseHttpCode":protected]=>  int(500) ["responseHeaders":protected]=>  array(7) {  
["server"]=>  string(61) "HTTP Upload Server Built on Dec 12 2012 15:53:08 (1355356388)"  
["content-type"]=>  string(16) "application/json" ["date"]=>  string(29) "Wed, 19 Dec 2012  
13:03:00 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) "52" } ["responseBody":protected]=>  string(52) "{ "error": { "code": 500, 
"message": null } } " ["accessKey"]=>  NULL }

これを前進させるための助けをいただければ幸いです。

4

1 に答える 1