1

私はこのページのコードを使用しています https://developers.google.com/youtube/v3/code_samples/php#upload_a_video 動画をYouTubeにアップロードしています。しかし、私は既に存在するプレイリストにアップロードされたビデオを置くことはできません。YouTube公式PHP SDK経由でプレイリストにYouTube動画を追加する方法

私はinsert方法があり、このクラスGoogle_Service_YouTube_Resource_PlaylistItemsを見つけましたが、私は、これは私はこれが応答

object(GuzzleHttp\Psr7\Request)#698 (7) { 
    ["method":"GuzzleHttp\Psr7\Request":private]=> 
    string(4) "POST" 
    ["requestTarget":"GuzzleHttp\Psr7\Request":private]=> 
    NULL 
    ["uri":"GuzzleHttp\Psr7\Request":private]=> 
    object(GuzzleHttp\Psr7\Uri)#749 (7) { 
    ["scheme":"GuzzleHttp\Psr7\Uri":private]=> 
    string(5) "https" 
    ["userInfo":"GuzzleHttp\Psr7\Uri":private]=> 
    string(0) "" 
    ["host":"GuzzleHttp\Psr7\Uri":private]=> 
    string(18) "www.googleapis.com" 
    ["port":"GuzzleHttp\Psr7\Uri":private]=> 
    NULL 
    ["path":"GuzzleHttp\Psr7\Uri":private]=> 
    string(25) "/youtube/v3/playlistItems" 
    ["query":"GuzzleHttp\Psr7\Uri":private]=> 
    string(29) "part=snippet%2CcontentDetails" 
    ["fragment":"GuzzleHttp\Psr7\Uri":private]=> 
    string(0) "" 
    } 
    ["headers":"GuzzleHttp\Psr7\Request":private]=> 
    array(3) { 
    ["Host"]=> 
    array(1) { 
     [0]=> 
     string(18) "www.googleapis.com" 
    } 
    ["content-type"]=> 
    array(1) { 
     [0]=> 
     string(16) "application/json" 
    } 
    ["X-Php-Expected-Class"]=> 
    array(1) { 
     [0]=> 
     string(35) "Google_Service_YouTube_PlaylistItem" 
    } 
    } 
    ["headerNames":"GuzzleHttp\Psr7\Request":private]=> 
array(3) { 
    ["content-type"]=> 
    string(12) "content-type" 
    ["host"]=> 
    string(4) "Host" 
    ["x-php-expected-class"]=> 
    string(20) "X-Php-Expected-Class" 
    } 
    ["protocol":"GuzzleHttp\Psr7\Request":private]=> 
    string(3) "1.1" 
    ["stream":"GuzzleHttp\Psr7\Request":private]=> 
    object(GuzzleHttp\Psr7\Stream)#730 (7) { 
    ["stream":"GuzzleHttp\Psr7\Stream":private]=> 
    resource(589) of type (stream) 
    ["size":"GuzzleHttp\Psr7\Stream":private]=> 
    NULL 
    ["seekable":"GuzzleHttp\Psr7\Stream":private]=> 
    bool(true) 
    ["readable":"GuzzleHttp\Psr7\Stream":private]=> 
    bool(true) 
    ["writable":"GuzzleHttp\Psr7\Stream":private]=> 
    bool(true) 
    ["uri":"GuzzleHttp\Psr7\Stream":private]=> 
    string(10) "php://temp" 
    ["customMetadata":"GuzzleHttp\Psr7\Stream":private]=> 
    array(0) { 
    } 
    } 
} 

   $resourceId = new \Google_Service_YouTube_ResourceId(); 
       $resourceId->setVideoId($status["id"]); 
       $resourceId->setKind('youtube#video'); 



       $playlistItemSnippet = new \Google_Service_YouTube_PlaylistItemSnippet(); 
       $playlistItemSnippet->setTitle('First video in the test playlist'); 
       $playlistItemSnippet->setPlaylistId($playlistId); 
       $playlistItemSnippet->setResourceId($resourceId); 


       $playlistItem = new \Google_Service_YouTube_PlaylistItem(); 
       $playlistItem->setSnippet($playlistItemSnippet); 
       $playlistItemResponse = $youtube->playlistItems->insert(
        'snippet,contentDetails', $playlistItem, array()); 

思い付いたものです

にそれを使用する方法を見当もつかない

注: API経由で動画をアップロードして、認証と接続、基本的な要件はすべてOKです

答えて

0

ここには、SO postの出発点があります。

これは、ユーザーの問題を解決するコードです。

また、下記の関連する投稿を確認して、プレイリストに動画をアップロードする方法を知ることもできます。

+0

私はすでに、質問を投稿する前にリンクを読んで、彼らは私が午前の問題に関連していません。 と私はコードが何を投稿したのかわからない! –

+0

@DiaaSaadaあなたの問題を解決しましたか? 「はい」の場合は、同じ問題に直面しているので解決策を投稿してください。 – semsem

+0

はい。私は、プレイリストを設定する前に '$ client'と' $ service 'を再初期化しました –

関連する問題