house plans
Free Shipping on All House Plans!
Question or to order
Home >> Technology >> Article
Search entire site
DREAM. LEARN. DISCOVER... GET STARTED.
Technology
Technology

Ping Feedburner, Ping-o-Matic, Google, Technorati and All the Other Cool Kids Using ASP.NET and Some Magic

Tags : , , ,
Published On : 01-30-2008
Author : Steve Donegan
4779 Views
ShareThis

It has been a long time coming, but we have finally managed to migrate away from Community Server to our own custom blog software that is integrated directly into the web site. The reasons for the change are numerous including the need to customize the look and navigation of our blogging software and our desire to provide readers a more streamlined experience.

The final part of the migration to this new system was released tonight. This final piece being the ability to ping the various providers that watch new blog posts. The code required to do this is not difficult to write. I am posting it below in case anyone is interested in how it is done.

Ironically enough this post will be the first one to actually use the ping service. Here's a link that helped me figure out how to do the ping and here's the code:

using System;
using System.IO;
using System.Net;
using System.Text;
using System.Xml;
using ThePlanCollectionCore.Utils;

namespace ThePlanCollectionCore.DataFeeds
{
    /// <summary>
    /// Wrapper for xml rpc service
    /// that can ping ping-o-matic and other services
    /// when your blog is updated.
    /// </summary>
    static public class Ping
    {
        // List of services that accept an xml rpc ping.
        // If you surf around the net you will find many other
        // services but many of them are offline or 
        // appear to be junk.  Stick with the main ones.
        static private string [] _Services = {
            "http://rpc.pingomatic.com",
            "http://blogsearch.google.com/ping/RPC2",
            "http://www.blogsnow.com/ping",
            "http://www.wasalive.com/ping/"
            };


        /// <summary>
        /// Sends a ping to the above services using the given website name 
        /// and url
        /// </summary>
        /// <param name="websiteName">The name of the website or blog
        /// that has been updated.</param>
        /// <param name="websiteUrl">The url of the website or blog
        /// that has been updated.  This should be an absolute root url
        /// not a direct link to the individual page that has been updated.</param>
        public static void Send(string websiteName, string websiteUrl)
        {
            for (int i = 0; i < _Services.Length; i++)
            {
                try
                {
                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(_Services[i]);
                    request.Method = "POST";
                    request.ContentType = "text/xml";
                    request.Timeout = 3000;

                    // Add in the updated page
                    BuildRequest(request, websiteName, websiteUrl);

                    // Send off the request
                    request.GetResponse();
                }
                catch (Exception ex)
                {
                    // Log the error.
                    Error err = new Error();
                    err.Title = "Ping Request Failure";
                    err.Body = "Ping to " + _Services[i] + " failed with error: " + ex.Message;
                    err.Save();
                }
            }
        }

        /// <summary>
        /// Adds the requred xml to the request.  This includes the website name and url
        /// along with the method name 'ping' that will tell the remote servers that
        /// and update has been made
        /// </summary>
        /// <param name="request">A http webrequest generated by the method 'Send' above.</param>
        /// <param name="websiteName">The name of the website or blog
        /// that has been updated.</param>
        /// <param name="websiteUrl">The url of the website or blog
        /// that has been updated.  This should be an absolute root url
        /// not a direct link to the individual page that has been updated.</param>
        private static void BuildRequest(HttpWebRequest request, string websiteName, string websiteUrl)
        {
            Stream stream = request.GetRequestStream();
            using (XmlTextWriter writer = new XmlTextWriter(stream, Encoding.ASCII))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("methodCall");
                writer.WriteElementString("methodName", "ping");
                writer.WriteStartElement("params");
                writer.WriteStartElement("param");
                
                // Add the name of your website here
                writer.WriteElementString("value", websiteName);
                writer.WriteEndElement();
                writer.WriteStartElement("param");

                // The absolute URL of your website - not the updated or new page
                writer.WriteElementString("value", websiteUrl);
                writer.WriteEndElement();
                writer.WriteEndElement();
                writer.WriteEndElement();
            }
        }
    }
}
COMMENTS
RELATED ARTICLES
Best Practices for Pipes and Plumbing in a New House Plan
House Plans 101
Ping Feedburner, Ping-o-Matic, Google, Technorati and All the Other Cool Kids Using ASP.NET and Some Magic
Technology
Landscaping, Make or break a great house design.
House Plans
Installing a putting green in our backyard
House Plans

Search House Plans

Bedrooms
 1  2  3  4  5+
Bathrooms
 1  1½  2  2½  3  3½  4+
Stories Garage Bays
 1  1½  2  1  2  3+
Square Feet
to
View Results
Enter Plan #:
HOUSE PLANS 101
FAQ
Glossary of Terms
Understanding Blueprints
Understanding Copyright
What's included in a set of house plans?
Why pre-drawn house plans?
MOST POPULAR ARTICLES
Plans with Indoor Basketball Courts
House Plans
Building a home plan with an indoor basketball court
House Plans
1. Building on slab vs. crawl space vs. basement? Advantages / disadvantage
House Plans
Garage Plans with Shops, Mother In-Law Suites, Apartments and Bonus Square Footage
House Plans
Luxurious Mountain Craftsman House Plans
House Plans
XML Encoding Problems - Hexadecimal Value 0x1A, is an Invalid Character
Technology
Beachfront, Coastal and Key West Home Plans
House Plans
The Finest Duplex, Town House, and Multi Unit Home Plans
House Plans
European and Luxury House Plans, Large and Small!
House Plans
The In-Law Suite Revolution
House Plans
ARTICLES BY TOPIC
A Frame House Plans A Home Builders Opinion Air Conditioning Tips Architecture beachfront house plans Beachfront Houseplans blueprints building log building lots building mistakes bungalow Bungalow House Plans Cape Cod House Plans celebrity home designs Coastal House Plans Color Photos Color Schemes Considerations for Building Foundations in a New House Plan Contemporary Style country house plans craftsman house plans Curb Appeal Custom vs Stock House Plans Customer Service
RECENT ARTICLES
Home Design Trends to Watch For in 2015
House Plans
The Right Appliances for your New Home Plan
House Plans 101
The Open Floor Plan: Stylish Living without Walls
House Plans
Regional Trends in Single Family Homes: Size, Price and Design Features Vary
House Plans 101
What to Expect from a New Home Inspection
House Plans 101
Pacific Northwest Style Adapts Architectural Designs to Region’s Landscape & Climate
House Plans
Put Some Halloween Magic and Mystery in Your Home
House Plans
Window Designs for Your New House Plan
House Plans 101
Come Into My House: Stylish Entrances That Make a Statement
House Plans
Wired Stuff and the Evolution of House Plans
House Plans 101
© 2014 The Plan Collection, LLC