订阅 youtube api v3 推送通知时如何接收和处理数据?

How to receive & process data when I subscribe to youtube api v3 push notification?

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

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

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

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

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

The YouTube Data API (v3) supports push notifications via PubSubHubbub, a server-to-server publish/subscribe protocol for Web-accessible resources. Notifications are pushed out to subscribers via HTTP webhooks, which is much more efficient than polling-based solutions.

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

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


编辑: 我可能应该为此问一个新问题......但无论如何......我试过这个频道(https://www.youtube.com/channel/UCATp8LNTjzjNlLxdArp0Myg);但是当我尝试订阅时它说 "restricted topic"(我没有提供 token 因为它是一个 public 频道)。与任何其他频道 ID 相同。我的回调服务器有问题吗?我还尝试将 runscope url 作为回调服务器进行测试。但这并没有帮助。

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

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

和相关的 Whosebug 问题:

Youtube API - Subscribing to Push Notifications

不幸的是,尽管您可以关注问题并跟踪任何进展,但似乎没有人提供解决方案。