簡體   English   中英

使用 Vimeo API 重命名視頻

[英]Rename video with Vimeo API

我希望使用 Vimeo Api 和 Google Apps 腳本重命名我的視頻。 我成功地讓 API 將視頻移動到文件夾中(使用與下面幾乎相同的語法),但我終生無法重命名。 這非常令人沮喪。

是參考,下面是我的代碼-它只是返回視頻信息,就好像我沒有嘗試更改任何內容一樣,即使我顯然使用的是“PATCH”調用,而不是“GET”。 我打算把'name'參數放在哪里?

function renameVideo(){

  var newName = 'thisismynewname';
  var url = 'https://api.vimeo.com/videos/_________?name=' + newName;

  var options = { 
    'method': 'PATCH',
    'muteHttpExceptions': true,
    'contentType': 'application/json',
    'headers': {
      'Accept':'application/vnd.vimeo.*+json;version=3.4',
      'Authorization': "Bearer " + token,
    },
    //Note that I've also tried 'name' : 'thisismynewname' here too
  };

  var response = UrlFetchApp.fetch(url, options);  
  Logger.log(JSON.parse(response).name); //it just returns the *current* name not the new one, and doesn't change it

}

當我看到Edit a video 的官方文檔時,似乎請求正文中包含了name 那么這個改裝怎么樣呢?

修改后的腳本:

function renameVideo(){
  var newName = 'thisismynewname';
  var url = 'https://api.vimeo.com/videos/_________';  // Modified

  var options = { 
    'method': 'PATCH',
    'muteHttpExceptions': true,
    'contentType': 'application/json',
    'headers': {
      'Accept':'application/vnd.vimeo.*+json;version=3.4',
      'Authorization': "Bearer " + token,
    },
    'payload': JSON.stringify({name: newName})  // Added
  };

  var response = UrlFetchApp.fetch(url, options);  
  Logger.log(JSON.parse(response).name);
}
  • 內容類型是application/json

參考:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM