house plans
FREE Shipping on All House Plans!
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
4511 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
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
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
1. Building on slab vs. crawl space vs. basement? Advantages / disadvantage
House Plans
Luxurious Mountain Craftsman House Plans
House Plans
The Finest Duplex, Town House, and Multi Unit Home Plans
House Plans
The In-Law Suite Revolution
House Plans
Florida and California House Plans With a Tuscan Style
House Plans
European and Luxury House Plans, Large and Small!
House Plans
Country Porches and Beautiful Farmhouses
House Plans
2x4 or 2x6 construction?
House Plans
Craftsman House Plans from Extreme Makeover: Home Edition
House Plans
Luxury House Plans
House Plans
ARTICLES BY TOPIC
A Frame House Plans A Home Builders Opinion Air Conditioning Tips Architecture Beachfront Houseplans blueprints building lots bungalow Bungalow House Plans Cape Cod House Plans Coastal House Plans Color Photos Color Schemes Contemporary Style country house plans craftsman house plans Curb Appeal Custom vs Stock House Plans Customer Service Design design trends Do-It-Yourself Door Hardware Door knobs Doorknobs Dream Homes Engineering House Plans european house plans Exterior Materials Extreme Makeover Farmhouse House Plans Feng Shui Floor plans Floorplan Layout Frank Lloyd Wright French Country Home Design french house plans Garage Plans Garages green design green house plans Halloween house high performance house plans Home Builders home buying home design Home Design Trends Home Designers Home Designs
RECENT ARTICLES
Trends to Build Home Plans that Embrace Nature and the Environment
House Plans
From Log Cabins to Southfork Ranch and Everything in Between… Variety Spices Texas Style Homes
House Plans
The Great Room: A Throwback to Medieval Times Finds Its Way in the Modern Age
House Plans
“Girl Power” in the 1900s: The First Women Architects Find Success in a Man’s World
House Plans
New Technologies for the Conscious Home Save Energy
Technology
Ready for Your Own Vacation Home? Here Is What to Look For
House Plans
Historical Progression of 3D Printing From Prototypes to 3D House Plans to Robotics
House Plans
What to Look for in an Affordable House Plan: Simplicity, Efficiency and Practicality –With Style!
House Plans
Design Trends in Renovation & House Plans for Home Builders
House Plans
The French House Plan: An Eclectic Mix of the Romantic, Rustic, and Majestic
House Plans
© 2014 The Plan Collection, LLC