c# - 如何在 YouTube 用户上传视频时调用函数?

标签 c# youtube-data-api

我正在尝试制作一个简单的聊天机器人,它会在某个 channel 上传视频时发送一条消息,最好是包含视频的名称和视频的超链接。

YouTube 的 API 很奇怪,我完全不知道如何处理。

这是我目前所拥有的:

using System;
using System.Linq;
using Google.Apis.Services;
using Google.Apis.YouTube.v3;

YouTubeService service = new YouTubeService(new BaseClientService.Initializer() {
    ApiKey = apiKey,
    ApplicationName = "GoodApp"
});

var getChannel = service.Channels.List("snippet");
getChannel.Id = channelId;

var response = getChannel.Execute();

var channel = response[0]; //now what?

最佳答案

使用 the YouTube PubSubHubbub service当 channel 上传新视频、更改视频标题或更改视频描述时,您可以收到推送通知。从该页面引用有关设置的信息:

  1. Set up a callback server that can handle incoming Atom feed notifications.
  2. Use the Google hub to subscribe to receive push notifications:
    • Set the mode to subscribe. (Or set the mode to unsubscribe to cancel a subscription.)
    • Set the callback URL to the URL that you set up in step 1.
    • Set the topic URL to https://www.youtube.com/xml/feeds/videos.xml?channel_id=CHANNEL_ID, where CHANNEL_ID is the YouTube channel ID for which you want to retrieve push notifications.
  3. Process notifications sent to your callback server. [...]

不幸的是,回调服务器不仅仅是几行代码,而且这取决于您运行的服务器类型。如果您了解 PHP、AppEngine 或 Go,订阅者存储库位于 PubSubHubbub可能会有帮助,否则搜索引擎似乎对我有很好的结果。

关于c# - 如何在 YouTube 用户上传视频时调用函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37913009/

相关文章:

java - YouTube API v3 中的 NullPointerException

2D 游戏中对象的 C# 结构

c# - datatable constraintsexception发生在dt.load(reader)时

c# - 如何在 C# 中更改 NetworkAdapter 的名称?

ios - iOS上载带有视频信息GTLServiceYoutube的视频

youtube - 如何使用YouTube API V3仅查询360个视频

c# - 将 Java 库导入 C#

c# - ITextSharp 整页高度布局

asp.net - 根据视频类别为特定关键字过滤YouTube搜索结果

ios - 在 iPad 上全屏启动 YTPlayerView