【问题标题】:Rename video with Vimeo API使用 Vimeo API 重命名视频
【发布时间】:2020-08-15 16:47:09
【问题描述】:

我希望使用 Vimeo Api 和 Google Apps 脚本重命名我的视频。我成功地让 API 将视频移动到文件夹中(使用与下面几乎相同的语法),但我一生都无法重命名。非常令人沮丧。

Here 是参考,下面是我的代码 - 它只是返回视频信息,就好像我没有尝试更改任何内容一样,即使我显然使用的是“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

}

【问题讨论】:

    标签: javascript api google-apps-script vimeo vimeo-api


    【解决方案1】:

    当我看到the official document of 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

    参考:

    【讨论】:

    • 先生,您是冠军。
    猜你喜欢
    • 1970-01-01
    • 2014-10-10
    • 2016-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-17
    • 2013-03-17
    相关资源
    最近更新 更多