使用pubsubhubbub订阅youtube

大约的步骤见https://developers.google.cn/youtube/v3/guides/push_notifications

1、Set up a callback server that can handle incoming Atom feed notifications.

2、Use the https://pubsubhubbub.appspot.com/subscribe 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.

这里需要注意的是,点击Do it 会显示空白页面,返回的http code 是204 或者 200

判断是否订阅成功的方法:
还是打开https://pubsubhubbub.appspot.com/subscribe,在Subscriber Diagnostics 下填上订阅的资料,点击Get Info,结果如果显示 verified,那么就表示订阅成功。

订阅客户端的代码形式应当如网页https://stackoverflow.com/questions/29611459/youtube-api-subscribing-to-push-notifications

entry->id, 9);
$channel_id = substr((string)$xml->entry->author->uri, 32);
$published = (string)$xml->entry->published;

return array(
'video_id'=>$video_id,
'channel_id'=>$channel_id,
'published'=>$published
);
}