本文介绍了如何接收 &当我订阅 youtube api v3 推送通知时处理数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据此https://developers.google.com/youtube/v3/guides/push_notifications

我可以订阅 YouTube 频道 &接收任何新视频的推送通知.

I can subscribe to a youtube channel & receive push notification for any new video.

我的回调服务器是一个解释 POST/GET 数据的 php 脚本:

My callback server is a php script which interprets POST/GET data:

<?php
if (isset($_GET['hub_challenge'])) {
  print $_GET['hub_challenge'];
}
else {
  $xml=file_get_contents("php://input");
  file_put_contents('endpoint.txt',$xml);
}
?>

但是 $xml 是空的.在文档中它说:

But $xml is empty. In the docs it says:

YouTube 数据 API (v3) 支持通过以下方式推送通知PubSubHubbub,一种服务器到服务器的发布/订阅协议,用于可通过网络访问的资源.通知被推送给订阅者通过 HTTP webhooks,这比基于轮询的效率高得多解决方案.

但它没有指定它如何发送数据......无论是在POST正文中还是在其他地方.

But it does not specify how does it send the data....whether in POST body or in somewhere else.

那么如何在我的脚本中获取 atom 提要?

So How do I get the atom feed in my script?

我可能应该为此问一个新问题……但无论如何……我尝试过这个频道(https://www.youtube.com/channel/UCATp8LNTjzjNlLxdArp0Myg);但是当我尝试订阅时,它说受限主题"(我没有提供令牌,因为它是一个公共频道).任何其他频道 ID 都相同.我的回调服务器有问题吗?我还尝试将 runscope url 作为回调服务器进行测试.但它没有帮助.

I should probably ask a new question for this...but anyway....I tried this channel (https://www.youtube.com/channel/UCATp8LNTjzjNlLxdArp0Myg); but when I try to subscribe it says "restricted topic" (I did not provide token as it is a public channel). Same for any other channel ID. Is something wrong with my callback server? I also tried runscope url as a callback server for testing. But it did not help.

推荐答案

其他人也有类似的问题.这是问题日志:

Others are having similar problems. Here is the issue log:

https://code.google.com/p/gdata-issues/issues/detail?id=7138

和相关的 StackOverflow 问题:

and related StackOverflow question:

Youtube API - 订阅推送通知

不幸的是,虽然您可以跟踪问题并跟踪任何进展,但似乎没有人提供解决方案.

Unfortunately, no one seem to provide a solution although you can follow the issue and track any progress.

这篇关于如何接收 &amp;当我订阅 youtube api v3 推送通知时处理数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 08:52