Google Blog Search Pinging REST Client

My WordPress blog has not been showing up in the Google Blog Search so I decided to create a REST Client to ping it using their Google Blog Search Pinging Service API. I created that last week and ran it a few times to test it. Tonight I was pleased to find several of my blog posts showing up in the search results. I searched on the uncommon words “YouCloud” and “YouComment” and found my posts listed first.

I created my REST client using ASP.NET because that is my area of expertise. I could not find many examples of REST clients in ASP.NET but it is really just a matter of making a simple web request. Most developers would probably use PHP and CURL (Client URL Library Functions) which is very versatile in its ability to handle cookies, user agent strings, referrers, custom headers, and post fields. Hackers use CURL a lot because it can automate the process of sending web traffic. However ASP.NET is also capable of handling all aspects of making web requests and the Google Blog Search Pinging Service API is pretty simple. Below is my code for pinging the Google Blog Search:

   1: Imports System.Net
   2: Imports System.Xml
   3: Imports System.IO
   4: Imports System.Diagnostics
   5:  
   6: Partial Class GooglePinger
   7:     Inherits System.Web.UI.Page
   8:  
   9:     ' create XML document as a global object
  10:     Public objXmlDocument As XmlDocument = New XmlDocument()
  11:  
  12:     Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
  13:         ' Blog name
  14:         Dim strName = Server.HtmlEncode("Williamsport Web Developer Weblog")
  15:         ' Blog web address
  16:         Dim strUrl = Server.HtmlEncode("http://www.williamsportwebdeveloper.com/cgi/wp/index.php")
  17:         ' Blog RSS feed address
  18:         Dim strChangesURL = Server.HtmlEncode("http://williamsportwebdeveloper.com/cgi/wp/?feed=rss2")
  19:         ' REST Url
  20:         Dim strRESTUrl As String = "http://blogsearch.google.com/ping?name=" & strName & "&url=" & strUrl & "&changesURL=" & strChangesURL
  21:         Debug.WriteLine(strRESTUrl, "strRESTUrl")
  22:         Dim HttpSite As Uri = New Uri(strRESTUrl)
  23:         ' Send web request
  24:         Dim objWebRequest As HttpWebRequest = CType(WebRequest.Create(HttpSite), HttpWebRequest)
  25:         objWebRequest.KeepAlive = False
  26:         objWebRequest.Timeout = 30000
  27:  
  28:         Try
  29:             '  Get the response to the web request
  30:             Dim objWebResponse As WebResponse = objWebRequest.GetResponse()
  31:             ' Use a stream reader to read the response
  32:             Dim objStreamReader As StreamReader = New StreamReader(objWebResponse.GetResponseStream(), System.Text.Encoding.UTF8)
  33:             lblMessage.Text = objStreamReader.ReadToEnd()
  34:  
  35:         Catch ex As Exception
  36:             lblErrorMessage.Text = ex.ToString()
  37:         End Try
  38:  
  39:     End Sub
  40: End Class
This entry was posted in General, Programming, Web and tagged , , , , . Bookmark the permalink.

One Response to Google Blog Search Pinging REST Client

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit exceeded. Please complete the captcha once again.