Zheng @ playpoly Sr 200909
Notes for writing earlier. It may be helpful to pubsubhubbub fans.
I. Advantages of enabling the pubsubhubbub protocol to update playlist Sr data:
Fast.
Almost a Google Reader user shares this articleArticleIn a few seconds, we can import the data into the database.
By polling every user's Google Reader shared items feed, it may take dozens or even dozens of minutes for an update to be written into the database. As the number of listeners increases, polling slows down, And the socket link is reset for a period of time because a user shares sensitive words in an article, if the request is too frequent and too concurrent, Google will reset your link.
But there will also be some problems, which will be explained later.
II. Introduction to the pubsubhubbub protocol:
Working Principle and Quick Start of kangye pubsubhubbub;
Kangye [tutorial] how to use the pubsubhubbub protocol;
Some of my supplements to the tutorials of Kang Ye pubsubhubbub;
The value of Tim's pubsubhubbub.
3. Understand the interaction between the hub server and you:
Defined in the Protocol,HubServer:
1. Send a verify subscriber request, requesting the subscriber to return the 200 status code and the challenge code.
2. Push the updated data of the subscribed Google Reader shareds items to the subscriber.
3. Send an expiration request to determine whether to continue renewal. Ask the subscriber to confirm the request.
Generally, yourProgramThe role is subscriber, and http: // pubsubhubbub .appspot.com/is the hub server.
Therefore, playgroup Sr puts all three tasks on a Web server for processing. The program provides the web entry and processing framework by twisted.
Iv. callback address Design
Although the data sent by the hub server (in XML format) indicates the shared items, the following fields are used:
<ID> tag: Google.com, 2005: Reader/user/15221435823542888940/State/COM. Google/broadcast </ID>
To match the corresponding user in the database according to this ID field, the SR also needs to perform a SELECT query.
Therefore, when a subscription request is initiated, different callback addresses are specified for different users. The callback address allows you to add necessary parameters.
5. Add subscription status for users
In some cases, You Need To unsubscribe a shared items instance (because the quality of shared articles is too poor), so that the hub will not send any updates, so you need a specific user status.
The Unsubscription process is the same as the subscription process, except that the hub. Mode value is 'unsubscribe '.
Therefore, the user must have a subscription status for the sixth consideration.
6. Make sure that the subscription does not expire after a period of time.
It is found that the hub server will lose its subscription to some feeds several days later, that is, the user clearly shared the article, but the subscriber was delayed to receive any update notifications.
In this case, you need to resend the request for subscription.
There may be two reasons: When the hub sends a "subscription expiration and re-Confirmation" request to the subscriber, the subscriber is busy and fails to respond in time; the hub server loses the subscription status.
VII. FAQs about pubsubhubbub:
1. Updating data is not necessarily the latest ones:
The storage status of the hub server has a certain time limit.If a user has not shared an article for a long time, such as having gone to bed, then when he shares the article again the next day, the hub will push all the data (8 entries. This indicates that within a period of time,For example, if the hub caches the data status pushed to the subscriber within one hour, it will be cleared after expiration.. Hub no longer remembers what data has been sent to you.
2. After a subscriber goes down, it may need to resend all subscription requests:
When your subscriber goes offline or goes down for a period of time (for example, one hour cannot be connected), hub will think that you will not renew your subscription, so it will not push the data to you. You need to initiate all subscription requests again.
3. Update speed:
It is not as often imagined. As soon as you click the shared button of an article in Google Reader, The Hub immediately pushes updates to the subscriber.Not necessarily.
In most cases, the new data is pushed in a few seconds. However, sometimes it may be the hub policy setting. A hub push is triggered only after two shared clicks. The pushed data content is the two articles shared in this batch.
Zheng Yu, Beijing