Jeremy Wadsworth
My Contribution to the ASP.NET Community


Welcome   
Welcome to my personal website. Here you will find blog posts related to web development as well as personal related interests. If you're here for the source code to my Personal Web Site Kit, please register and you'll receive an email when your account has been approved.


Latest Blog Entries

 Thursday, October 05, 2006


Ping Technorati using VB.NET in ASP.NET    

As I recently have explored the world of blogging, I found myself looking for code that would allow me to ping sites like Technorati.com and Feedburner.com. What I found was a nice piece of code in C# by Will Asrari. You can view the C# version of this code at http://www.willasrari.com/blog/programmatically-ping-technorati-using-c/00098.aspx.

However, I program in VB.NET so I converted the code and added the ability to ping several services. The following code will allow you to ping Technorati as well as the other links that are listed. All you need to do is add a call to the procedure in your submit or save event for blog entries.

 Public Shared Sub PingSites()
  Dim listToPing As New ArrayList
  Dim pingURL As String = ""
  Dim blogURL As String = "http://www.jeremywadsworth.com"
  Dim blogName As String = "Jeremy Wadsworth"

  With listToPing
   .Add("
http://rpc.technorati.com/rpc/ping")
   .Add("
http://api.feedster.com/ping")
   .Add("
http://ping.feedburner.com")
   .Add("
http://blog.goo.ne.jp/XMLRPC")
   .Add("
http://ping.blo.gs/")
   .Add("
http://ping.bloggers.jp/rpc/")
   .Add("
http://ping.blogmura.jp/rpc/")
   .Add("
http://ping.cocolog-nifty.com/xmlrpc")
   .Add("
http://ping.syndic8.com/xmlrpc.php")
   .Add("
http://rpc.blogbuzzmachine.com/RPC2")
   .Add("
http://rpc.blogrolling.com/pinger/")

  End With

  For i As Integer = 0 To listToPing.Count - 1
   Try
    pingURL = listToPing.Item(i).ToString
    Dim technoratiPing As HttpWebRequest = CType(WebRequest.Create(pingURL), HttpWebRequest)
    technoratiPing.Method = "POST"
    technoratiPing.ContentType = "text/xml"
    Dim streamPingRequest As Stream = CType(technoratiPing.GetRequestStream, Stream)
    Dim xmlPing As XmlTextWriter = New XmlTextWriter(streamPingRequest, System.Text.Encoding.UTF8)
    xmlPing.WriteStartDocument()
    xmlPing.WriteStartElement("methodCall")
    xmlPing.WriteElementString("methodName", "weblogUpdates.ping")
    xmlPing.WriteStartElement("params")
    xmlPing.WriteStartElement("param")
    xmlPing.WriteElementString("value", blogName)
    xmlPing.WriteEndElement()
    xmlPing.WriteStartElement("param")
    xmlPing.WriteElementString("value", blogURL)
    xmlPing.WriteEndElement()
    xmlPing.WriteEndElement()
    xmlPing.WriteEndElement()
    xmlPing.Close()
    Dim technoratiPingResponse As HttpWebResponse = CType(technoratiPing.GetResponse, HttpWebResponse)
    Dim streamPingResponse As StreamReader = New StreamReader(technoratiPingResponse.GetResponseStream)
    Dim strResult As String = streamPingResponse.ReadToEnd
    streamPingResponse.Close()
    technoratiPingResponse.Close()
   Catch ex As Exception
    'Add code here to flag a service as broken
   End Try
  Next
 End Sub


Make sure to set the blogURL and blogName variables to your blog information. With a little more code you could create a page to manage sites to ping. My idea for this page would be:
  • Store the sites-to-ping in the database
  • The table would have the fields SiteName, Active, and Failed
  • In the Try Catch you could flag a site as failed if it fails. Set the Failed to false if it succeeds.
  • On the Ping Site Management page display all the sites in a grid. Allow for add, editing, deleting.

I think you have the general idea.



jeremy at 5:17 PM | (16) Comments | Add a comment | Permalink





Commments
Damon said...

The Google adsense gives strange results sometimes. I am getting ad's on this page for Wadsworth OH hotels.

Monday, October 09, 2006 6:05 AM

KenP said...

Jeremy, This was a VERY useful post and was straight-forward enough that I can scale it to my needs. Thanks!

Friday, November 10, 2006 7:03 AM

Matt said...

Cool...I converted Will's c# code too for the technorati ping but didnt think to ping all those other services. Great idea.

Monday, November 20, 2006 5:35 PM

Jeremy said...

I'm glad the code was useful.

Monday, November 20, 2006 8:41 PM

Chris said...

Jeremy all i can say is thank god for you, i swear i love sites like this that just get down to the point and help everyone out with some awesome code! Worked perfect and if i do develop with it will definitly give u props :)

Wednesday, April 04, 2007 8:13 PM

Phil Wells said...

Hi I need to do this from my desktop application. Does anyone know whow to change the code?

Tuesday, February 19, 2008 4:26 AM

phil said...

Thanks, I am now using this.

Sunday, May 11, 2008 5:18 AM

Terrell said...

Thanks, Just what I was looking for and will use it!

Friday, March 13, 2009 1:55 AM

Sandesh Mitake said...

Hi dude , Thank you so much ... after got this code i feel very freely... I very hardly tried to ping urls.... Thank u so much

Thursday, April 22, 2010 12:14 PM

Ben said...

Been looking for hours to try and find this for vb.net, thanks very much!

Sunday, May 02, 2010 4:57 PM

Tiffany jewellery said...

Thank you so much ... after got this code i feel very freely... I very hardly tried to ping urls.... Thank u so much

Friday, July 16, 2010 9:04 PM

gucci mens wallet said...

<a href="http://mens-wallets.net/">men's wallet</a>, <a href="http://mens-wallets.net/">louis vuitton mens wallet</a>, <a href="http://mens-wallets.net/">gucci mens wallet</a>, <a href="http://mens-wallets.net/">prada mens wallet</a>.<br> Luxury goods are said to have high income elasticity of demand: as people become wealthier, they will buy more and more of the luxury good. This also means, however, that should there be a decline in income its demand will drop. Income elasticity of demand is not constant with respect to income, and may change sign at different levels of income.

Tuesday, July 20, 2010 9:46 PM

Gucci belt said...

<a href="http://guccibelt.net/">Gucci belts</a>, <a href="http://guccibelt.net/">Gucci belt</a>, fabulous <a href="http://guccibelt.net/">Gucci men's belt</a>, with high ratio of performance and price <a href="http://guccibelt.net/">Gucci belts for men</a>.<br>

Wednesday, August 18, 2010 4:38 AM

Gucci belt said...

<a href="http://guccibelt.net/">Gucci belts</a>, <a href="http://guccibelt.net/">Gucci belt</a>, fabulous <a href="http://guccibelt.net/">Gucci men's belt</a>, with high ratio of performance and price <a href="http://guccibelt.net/">Gucci belts for men</a>.<br>

Wednesday, August 18, 2010 4:39 AM

mbt shoes clearance said...

I am very enjoyed for this site. Its an informative topic. It help me very much to solve some problems. Its opportunity are so fantastic and working style so speedy. I think it may be help all of you. Thanks a lot for enjoying this beauty article with me. I am appreciating it very much! Looking forward to another great article. Good luck to the author! all the best!

Thursday, August 19, 2010 4:23 AM

hosting said...

That is a nice simple code to ping new blog post. Easy to set up and use.

Friday, August 20, 2010 3:02 PM

  Leave a comment

Enter Your Name:
 
Enter your website
Security code from image below:  
Need Custom Controls Work or Training?
   


Join WebHost4Life.com






If you would like to help support this project, please click the button below to make a small donation.