Pinging Technorati
17 November 2008 Tips  Marek Sienkiewicz
Bubble
Copy and paste the code below into your App_Code folder. To do this  right click App_Code choose Add New Item > Class  choose vb as the language and name the class PingTechnorati or something similar.
Next set the blog URL to your own blog address and the blogName to the information entered into the <title> tag in the <head> section of your blog HTML or  if you're generating the title dynamically Page.Title in the Page_Load event of your default page.
 
Imports Microsoft.VisualBasic
Imports System.Net
Imports System.Xml
Imports system.IO
 
Public Class PingTechnorati
   Public Shared Sub PingSites()
 
    Dim pingURL As String = "http://rpc.technorati.com/rpc/ping"
    Dim blogURL As String = "blogURL"
    Dim blogName As String = "blogName"
   
   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()
      
    End Sub
End Class
 
Next simply call the method in your submit event for blog enteries.
 
Protected Sub btnPost_Click(ByVal sender As Object, ByVal  e As e System.EventArgs) Handles bntPost.Click
 
      PingTechnorati.PingSites()
 
So now every time you post an article to your blog Technorati is automatically pinged.
 
 





Please post your comments:

Name

Email
                           

   

Enter the text you see in the box:

Captcha Image