c#-YouTube用户上传视频时如何调用函数?
作者:互联网
我正在尝试创建一个简单的聊天机器人,该聊天机器人会在某个频道上传视频时发送一条消息,最好是带有视频名称和视频的超链接.
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,您可以在频道上传新视频,更改视频标题或更改视频说明时获得推送通知.从该页面引用有关设置的信息:
- Set up a callback server that can handle incoming Atom feed notifications.
- Use the 07001 hub to subscribe to receive push notifications:
- Set the mode to
subscribe
. (Or set the mode tounsubscribe
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
, whereCHANNEL_ID
is the 07002 for which you want to retrieve push notifications.- Process notifications sent to your callback server. […]
不幸的是,回调服务器不仅包含几行代码,而且还取决于您所运行的服务器类型.如果您知道PHP,AppEngine或Go,则PubSubHubbub上的订户存储库可能会有所帮助,否则搜索引擎似乎对我有很好的效果.
标签:youtube-data-api,c 来源: https://codeday.me/bug/20191026/1940431.html