2012-11-01 90 views
0

我想使用客戶端庫v3將視頻上傳到youtube。使用php客戶端庫v3將視頻上傳到youtube

第3版庫是實驗和不具有多文檔 (提供不包括YouTube的樣品)

我已經正確認證的用戶使用OAuth 2.0。當我有訪問令牌時,我正在嘗試使用此代碼。

if ($client->getAccessToken()) { 
    $snippet = new Google_VideoSnippet(); 
    $snippet -> setTitle = "Demo title"; 
    $snippet -> setDescriptio = "Demo descrition"; 
    $snippet -> setTags = array("tag1","tag2"); 
    $snippet -> setMimeType = 'video/quicktime'; 

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

    // Not sure what to do now.... 

    $_SESSION['access_token'] = $client->getAccessToken(); 
} 

docs

我需要提供部分參數

The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. 

The part names that you can include in the parameter value are snippet, contentDetails, player, statistics, status, and topicDetails. However, not all of those parts contain properties that can be set when setting or updating a video's metadata. For example, the statistics object encapsulates statistics that YouTube calculates for a video and does not contain values that you can set or modify. If the parameter value specifies a part that does not contain mutable values, that part will still be included in the API response. 

但是缺乏足夠的文件,除了它,我無法理解一個Python的例子。 (例子是在鏈路的底部,我公司提供)

請,不給例子/鏈接Zend庫,它使用的auth-子,我不想。 我想使用oauth 2.0。

回答

1

上傳視頻的代碼如下所示。

$youtubeService->videos->insert($part, Google_Video $postBody, $optParams = array()); 

「部分」是您希望請求返回的內容。在這種情況下,可能只是status,它會返回有關上載狀態的信息。

的谷歌PHP客戶端庫的版本可能是舊的,所以你要在https://code.google.com/p/google-api-php-client/

+0

哦檢出源,我只注意到代碼已經有2天前更新。我剛剛檢查出來。讓我試試,我會告訴你,一旦我測試 – Jashwant

+0

工作,我使用的是舊版本(發佈版本),它沒有任何方法'插入' – Jashwant

相關問題