如何删除我的 Vimeo 帐户中的视频?

How do I delete a video in my Vimeo account?

如何在 .Net Core 中使用 C# 使用 Vimeo API 删除我的 Vimeo 帐户中的视频?

如果您有一个 Vimeo 帐户(至少它在 Plus 级别及以上)并且创建了一个应用程序,给予该应用程序删除权限,获得该应用程序的访问令牌,并且有一个您要删除的视频的视频编号。

在 class 中输入以下代码:

HttpClient httpClient = new HttpClient();


    public async Task deleteVideo(string videoNumber, string accessToken) 
    {

        try
        {

            string vimeoApiUrl = "https://api.vimeo.com/videos/" + videoNumber; // Vimeo URL


            var body = "{}";

            HttpContent content = new StringContent(body);

            using (var requestMessage = new HttpRequestMessage(HttpMethod.Delete, vimeoApiUrl))
            {
                requestMessage.Headers.Authorization =
                    new AuthenticationHeaderValue("Bearer", accessToken);
                requestMessage.Headers.Add("Accept", "application/vnd.vimeo.*+json;version=3.4");
                requestMessage.Headers.Add("ContentType", "application/x-www-form-urlencoded");
                requestMessage.Content = content;
                var response = await httpClient.SendAsync(requestMessage).ConfigureAwait(false);

                response.EnsureSuccessStatusCode();
            }

        }
        catch (Exception err)
        {
            var errMessage = err.Message;
            Console.WriteLine("In deleteVideo() error: " + err.Message);
        }

    }

从 class 中调用它:

await deleteVideo(videoNumber, accessToken).ConfigureAwait(false);