RSSMicro.com Search - RSS Feed Search Engine - RSS Feed Directory
Real-Time Search Powered by FeedRank®
 Relevant real-time search results on millions of RSS feedsTop Stories  |  FeedRank® Checker
   


RSSMicro Real-Time Protocol Implementations

To request a HubKey or for more information click here


PubSubHubBub
URL:
Specs:
Publisher Usage:
Up to 1,000 notifications/day, for more usage request a HubKey.
Subscriber Usage:
Up to to 1,000 feeds, for more usage request a HubKey.



rssCloud
URL:
Specs:
Publisher Usage:
Up to 1,000 notifications/day, for more usage request a HubKey.
Subscriber Usage:
Up to 1,000 feeds, for more usage request a HubKey.



PubSubHubBub Implementation on .NET Framework

Complexity of the process is mostly on the hub, publishers and subscribers have to make following changes to use the hub.

Here are some sample codes in C# programming language:


Publishers
Add our hub address to your feed:
This is to let your feed subscribers know that your feed is working with our PSHB hub.

If your blog paltform or feed generator supports PubSubHubBub plugins you can simply add RSSMicro hub address at (http://pubsubhub.rssmicro.com/) to the plugin so that your blog can work with RSSMicro hub. See Wordpress PubSUbHubBub Plugin for more details.

If your feed application does not support PSHB plugin add PSHB XML tag to your feed.

PubSubHubBub XML tag is added to the header section of an RSS feed:

<?xml version="1.0" encoding="UTF-8"?> 
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> 
    <channel> 
        .                 
        .                 
        .                 
        .                 
        <atom:link rel="hub" href="http://pubsubhub.rssmicro.com" /> 
        .                 
        .                 
        .                 
        <item> 
        . 
        </item> 
        <item> 
        . 
        </item>         
    </channel> 
</rss>
Send hub notification after feed updates:
After you update your feed, a notification has to be sent to the hub, the hub will then visit your feed and identify feed updates, if the feed is updated the hub will schedule to push the content to the subscribers.

Sample C# code on how to notify a hub:

After feed updates you must call NotifyHub method in your code:

NotifyHub("http://pubsubhub.rssmicro.com",{your feed url})


    private string NotifyHub(string HubURL, string Topic) 
    { 

        string data = ""; 
        string response = ""; 

        data = "hub.mode=publish"; 
        data += "&hub.url=" + Server.UrlEncode(Topic); 

        try 
        { 

            response = ExecutePostCommand(HubURL, data); 


        } 
        catch (Exception exp) 
        { 

            response = "error: " + exp.Message; 
             
        } 

        return response; 

    }     
     

    protected string ExecutePostCommand(string url, string data) 
    { 

        try 
        { 

            WebRequest request = WebRequest.Create(url); 
            request.ContentType = "application/x-www-form-urlencoded"; 
            request.Method = "POST"; 

            byte[] bytes = Encoding.UTF8.GetBytes(data); 
            request.ContentLength = bytes.Length; 

            using (Stream requestStream = request.GetRequestStream()) 
            { 
                requestStream.Write(bytes, 0, bytes.Length); 

                using (WebResponse response = request.GetResponse()) 
                { 
                    using (StreamReader reader = new StreamReader(response.GetResponseStream())) 
                    { 
                        return reader.ReadToEnd(); 
                    } 
                } 
            } 
             
        } 
        catch (Exception exp) 
        { 
             
            return "error: " + exp.Message; 

        } 

    }




Subscribers
Send a subscription request:
Once your PSHB enabled feed reader or other applications identify a PSHB hub for a feed, you have the option to subcriber to the feed using the hub. The reader or other applications have to send a subscription request to the hub along the feed URL and subscriber's callback URL.

Sample C# code on how to send subscription requests to a hub:

Call Subscribe method in your code:

Subscribe("http://pubsubhub.rssmicro.com","http://www.rssmicro.com/feeds/news.rss",{your call back url})


    private string Subscribe(string HubURL, string FeedURL, string CallBackURL) 
    { 

        string data = ""; 
        string response = ""; 

        data = "hub.callback=" + Server.UrlEncode(CallBackURL);  
        data += "&hub.mode=subscribe"; 
        data += "&hub.topic=" + Server.UrlEncode(FeedURL); 
        data += "&hub.verify=async"; 

        try 
        { 

            response = ExecutePostCommand(HubURL, data); 

        } 
        catch (Exception exp) 
        { 

            response = "error: " + exp.Message;             

        } 

        return response;         
         
    } 


    protected string ExecutePostCommand(string url, string data) 
    { 

        try 
        { 

            WebRequest request = WebRequest.Create(url); 
            request.ContentType = "application/x-www-form-urlencoded"; 
            request.Method = "POST"; 

            byte[] bytes = Encoding.UTF8.GetBytes(data); 
            request.ContentLength = bytes.Length; 

            using (Stream requestStream = request.GetRequestStream()) 
            { 
                requestStream.Write(bytes, 0, bytes.Length); 

                using (WebResponse response = request.GetResponse()) 
                { 
                    using (StreamReader reader = new StreamReader(response.GetResponseStream())) 
                    { 
                        return reader.ReadToEnd(); 
                    } 
                } 
            } 

        } 
        catch (Exception exp) 
        { 

            return "error: " + exp.Message; 

        } 

    }


Hub verifies intent of the subscriber:
After hub receives subscription requests and to verify the request the hub sends an HTTP GET request to the subscriber's callback URL as given in the subscription request. This request has following parameters:
   
   "hub.challenge" 
   "hub.mode"
   "hub.topic"
   "hub.lease_seconds"
   "hub.verify_token"
The subscriber MUST confirm that the hub.topic and hub.verify_token correspond to a pending subscription or unsubscription that it wishes to carry out. If so, the subscriber MUST respond with an HTTP success (2xx) code with a response body equal to the hub.challenge parameter. If the subscriber does not agree with the action, the subscriber MUST respond with a 404 "Not Found" response.

Sample code on how to process hub subscription verification requests on subscriber's callback URL:

    protected void Page_Load(object sender, EventArgs e) 
    { 

        string HUBChallenge = Request.QueryString["hub.challenge"]; 
        string HUBMode = Request.QueryString["hub.mode"]; 
        string HUBFeedURL = Request.QueryString["hub.topic"]; 
        string HUBLease_Seconds = Request.QueryString["hub.lease_seconds"]; 
        string HUBVerify_Token = Request.QueryString["hub.verify_token"]; 

        if (Subscription_Verified(HUBMode, HUBFeedURL, HUBVerify_Token)) 
        {  
           Response.Write(HUBChallenge);  
        } 
        else  
        {  
           Response.StatusCode = 404; 
           Response.StatusDescription = "Not found"; 
        }         

     } 
     
    private Boolean Subscription_Verified(string Mode, string FeedURL, string Token){ 
         
        //Verify the subscription request here         
        Boolean check = true; 

        return check; 
          
    } 
Processing the payload:
If the hub finds new updates on the feed, it pushes the content in the body of the request using HTTP POST to the subscriber's callback URL. Subscriber will receive a feed document that looks like the original but with old content removed.

Sample code on how to process the HTTP POST payloads on subscriber's callback URL:

    protected void Page_Load(object sender, EventArgs e) 
    { 

        StringBuilder respBody = new StringBuilder(); 
        string body = ""; 

        try 
        { 

           Stream ReceiveStream = Request.InputStream; 
           int count = 0; 
           Byte[] buf = new byte[8192]; 
           do { count = ReceiveStream.Read(buf, 0, buf.Length);  
                if (count != 0) 
                respBody.Append(Encoding.UTF8.GetString(buf, 0, count));  
           } while (count > 0); 

           body = respBody.ToString(); 

           Feed_Parser(body); 

        } 
        catch (Exception exp) 
        { 

           body = "error: " + exp.Message;  

        } 

    } 
    private void Feed_Parser(string body) 
    { 

            //RSS or Atom Feed Parser  

    }


References

For more information please visit PubSubHubBub Project







FeedCamp
Keyword Trends, Granular News on RSS Feeds

Top RSS Feeds - FeedCamp  Top RSS Feeds

New RSS Feeds - FeedCamp  New RSS Feeds


Tools
Submit feed, stay connected, browse directory and more...

  Submit Feed

  Featured RSS Feeds

  FeedRank® Checker

  Recently Submitted Feeds


  Search Widget

  News Alerts

  RSS Feed Directory


  API

  PubSubHubBub, rssCloud

Follow RSSMicro on

Follow RSSMicro on Twitter

Or

Follow RSSMicro on Facebook


Copyright © 2012 RSSMicro.com