Call us

How To Send XMLRPC Pings From Classic ASP

Tutorials 2 comments

If your website or blog runs on Wordpress or any other popular blog platform, then you probably already have the built-in ability to “ping” services such as Pingomatic and Google Blog Search. However, if like me you have developed a website or application from scratch using a custom platform, then you will need to build in the ability to send ping updates to these services.

Most of my developing is done in Classic ASP. I am learning php and .Net, but my background is ASP VbScript. One of the problems I came across with this new website that I mentioned is because it is custom, there was no “built-in” ping function….until now that is!

Overview

The website in question is FindLocalVehicles.co.uk. It allows people to list their vehicles (cars, boats, bikes etc) for sale. I have built in a “Motoring News” section that gets daily news posted, but I wanted to be able to notify the blog search websites when my website was updated. This is called “pinging”. A manual way is to browse to pingomatic.com, fill in the form and submit it, but I wanted an automatic solution.

After searching and testing, I have come up with the following.

This is how I wanted the process to work:

  1. Login to the admin section
  2. Post a new news story
  3. Automatically ping pingomatic with the details

So, here’s how we would go about it.

After the new post is submitted to the database, at the bottom of that page I added this function:

function SendPing(byval strBlogName, byval strBlogUrl, byval strPageUrl, byval strFeedUrl)

‘ build ping XMLRPC call
strData = “<?xml version=”"1.0″”?>”
strData = strData & “<methodCall>”
strData = strData & “<methodName>weblogUpdates.extendedPing</methodName>”
strData = strData & “<params>”
strData = strData & “<param>”
strData = strData & “<value>” & strBlogName & “</value>”
strData = strData & “</param>”
strData = strData & “<param>”
strData = strData & “<value>” & strBlogUrl & “</value>”
strData = strData & “</param>”
strData = strData & “<param>”
strData = strData & “<value>” & strPageUrl & “</value>”
strData = strData & “</param>”
strData = strData & “<param>”
strData = strData & “<value>” & strFeedUrl & “</value>”
strData = strData & “</param>”
strData = strData & “</params>”
strData = strData & “</methodCall>”

‘ post to Pingomatic XMLRPC ping URL
set objHttp = Server.CreateObject(”MSXML2.ServerXMLHTTP”)
objHttp.open “POST”, “http://rpc.pingomatic.com/”, false
objHttp.setRequestHeader “Content-Type”, “text/xml”
objHttp.setRequestHeader “Content-Length”, len(strData)
objHttp.Send strData

‘ check response
if (objHttp.status = 200) then
strReturn = objHttp.responseText
end if

‘ release object
set objHttp = nothing

‘ passback
SendPing = strReturn

end function

strData = SendPing(”The Title Of Your Website”, “The URL of your website”, “The URL of the new article”, “The URL of your RSS feed”)

Replace the bits in quotes on the line above with your website details

After that I redirect to a page and append the strData variable to the URL so I can display the returned message. If the ping is successful it says “Sent ping to 16 services”. If unsuccessful it tells you an error message.

Have fun!

Tagged : ,

Related Posts

2 Responses to “How To Send XMLRPC Pings From Classic ASP”

  1. shiplu Says:

    can you give a real world example??
    Can you tell what will be the call of SendPing() for this page??

    I just need to know the four paramters

  2. Ben Says:

    Shiplu, you simply call the function like the last red line above. Replacing the 4 variables with your site details, eg

    SendPing(”My Website”, “http://www.mywebsite.com”, “http://www.mywebsite.com/myarticle.asp”, “http://www.mywebsite.com/feed.xml”)

Leave a Comment