Thursday, 31 July 2008

How to check Google Checkout API has reached your callback page

In this post I will tell you how to find out if Google has actually reached your callback page, when using the Google Checkout Api.

There are several ways to check that Google is actually getting to your page.

1. Go into the Tools tab, then click on the integration console.

This will tell you if there are any errors that Google encountered trying to get to or run your page.

2. The next best way is to create a test event on your callback page that will fire when ever the page is run. This can be as simple as just writing a line to a text file, in fact using a text write is a good idea as you can write out all responses from Google and make sure are know which information is coming back, and whether it is correct or not.

A sample for this would be as follows

If you write the following into your callback page, a text will be written to a text file, if there is nothing written, Google has not run this page.

Sample 1 - Writing a simple line to a text file

Writes test line to TestFile.txt - TestFile.txt must exist in the same location on your server as you callback page, simple write the code below at the top of your callback page. If nothing is written Google has not reached your page, check the integration console as advised above.

'START OF CODE'

Dim fso, f, FilePath
Set fso = CreateObject("Scripting.FileSystemObject")
FilePath = Server.MapPath(".") & "\TestFile.txt"
Set f = fso2.CreateTextFile(FilePath, True)
f.WriteLine "Testing"

f.close

'END OF CODE'

Sample 2 - Writing Full Google XML response to text file

The following code will write the Google response to a text file called CompleteGoogleResponse.txt, which must exist in the same location as your callback page.

With this code you have two options, you can write it just below the LogMessage ResponseXML line in the sample callback.asp code provided by Google, just remove the last PrivateData and GNum lines.

or you can write it as is into the function called ProcessNewOrderNotification just write the code at the top of this function, and if all is well you will have a file with the full response XML from Google as well as your Google Order Number for this transaction and any private data your may have sent (NOTE remove the private data line if you do not send any in your original transaction), again if nothing is written Google failed to reach your page, check the integration console as advised above.

'START OF CODE'

Dim fso1, f1, FilePath1
Set fso1 = CreateObject("Scripting.FileSystemObject")
FilePath1 = Server.MapPath(".") & "\CompleteGoogleResponse.txt"
Set f1 = fso2.CreateTextFile(FilePath1, True)
f1.WriteLine "GoogleResponse=" & ResponseXml
f1.WriteLine "PrivateData=" & MyPrivateData.xml
f1.WriteLine "GNum=" & GoogleOrderNumber

f1.close

'END OF CODE'

NOTE

It must be said that if the above code is written into your callback page, and the text written to your file is something like GNum= but there is no information after the = sign, then Google has successfully hit your page, but failed to send you any information. Check the integration console as advised above.

I hope this makes sense, if you have any questions or want me to expand on any of this just drop me a comment or send me an email.

Thanks
Sean J Connolly
Visit AJAX Web Development Store




DMS - Document Management, Webmail
BuzzProperties.co.uk - Online Property Sales and Letting

Thursday, 22 May 2008

Google Search API Results

You may be custom to using the Google APIs for adding to your website or web application. I thought I would write a bit about why the results are not the same as the live Google system.

The 2 main API's that are used by developers from the Google network are the Map API and the search API, although there are other APIs in the Google arsenal, the Google Map API and Google Search API are 2 that return data.

The main question that I get asked is "Why do I get different results from using the API than that I do from using Google?".

The answer is mainly a two fold problem.

1. The issue with the API that relies on third party data, such as the Google Maps API, as most of the data Google uses for this API is not actually owned by Google. This is particularly true when it comes to the geo-coding, that is taken specific address information and turning into actual latitude and longitude on the planet for the Google Map to find. The main issue with this is that Google relies on purchased data to achieve this tasks, and in each country this is normally the postal services in that country.

This mean s that there are restrictions on what Google can do with this data, this is the main reason why when using the Google Map API you get different results than the actual Google Maps website, the Google Maps website data is different from the Google Maps API, just because of the restrictions placed on Google by licensees / owners of the data.

I know Google is working to improve the relationships and use of the data, so lets hope they can open up the world and the data in it.

2. The next issue other than licensing of the data is where the data comes from, this mainly fits with the Google Search API, as the Google search network is main up of different data centres, all of which have slightly different data. So you may get different results due to a different data centre being used, and as google route to data is different from a search on the Google website to using the Google Search API then the results can often be different.

It must also be pointed out that as a rtegisterd Google user Google remembers what you search for and improves your results, so when you use the Google website to search your results will be improved for a better match to what your looking for. However when you use the Google Search API this is not true, as the API returns raw data.

So I think that although we can use the Google APIs to build a mini Google world, it will never be the same as Google. Which makes sense after all the great guys and gals at Google allows us to use most things for FREE, so keep this in mind when coding. Look at what you are trying to do and ask yourself what you really want to do.

Thanks
Sean J Connolly
Visit AJAX Web Development Store





NotJustAJAX - Techy Blog
DMS - Document Management, Webmail
BuzzProperties.co.uk - Online Property Sales and Letting


Saturday, 10 May 2008

Robots.txt, SiteMaps - what are they and how do I use them?

I thought I would touch on what exactly a website map or sitemap is and how to make one and what to do with it. I will also talk about the robots.txt

Robots.txt

What is this?

The robots.txt file is a file you place on your website to tell the web spiders where they can and cannot go on your website.

One word of caution is that although the good web spiders will keep out of your website according to this file, others will not. So if you have content you really don't want to be seen, either move it, password protect it or whatever.

What does it look like?

The robots.txt file is simple a text file called robots.txt.

The main two parts to your robots.txt file are

  • User-agent - this tells a specific spider what to do i.e Googlebot
  • Disallow - this specifies which section of your site is restricted
  • Allow - this specifies which section of your website is not restricted

The basic structure is

User-agent: Googlebot

Disallow:

User-agent:*

Disallow:/

This example simply says that only Google can visit your website, and all other spiders are not allowed to visit. To restrict specific folders or files just do:

Disallow:/afoldername (this restricts access to http://www.yoursite.com/afoldername)

Disallow:/getoff.htm (this restricts access to http://www.yoursite.com/getoff.htm)

So an example which says that you want everything except your images folder spidered looks like:

User-agent:*

Disallow:/images

This means everything except your images folder will be spidered.

Why use it?

The purpose behind the robots.txt file is to give a route into your website, and if you have a large website you should restrict as much as possible, as the spiders will only spend so much time on your website. So the best thing to do is hide content they cannot see anyway, such as images.



Where to put it.

One your have created a robots.txt file, simply uploaded it to the root directory of your website, that is the http://www.yourwebsite.com location on your server, and you should be able to view it on your website as http://www.yourwebsite.com/robots.txt

Website Map or Sitemap

What is a website map or sitemap

The purpose of a sitemap if that it gives both the search engine spiders a useful map to follow when looking at your website, but it does the same for your users.

The search engines look at your site map and it give them an updated view of your website, which helps keep the indexing of your website up to date in the seaarch engine listings.

What does it look like

The website map or sitemap comes in 3 forms



  • HTML Form - this is the one for your end users

An HTML sitemap can been any form you wish that gives a nice visual overview of your website, it is normally a cut down page on your website with a simply list of links on your website.

  • XML Sitemap - this is an XML list of your website, containing the links on your website, this is the one you submit to the search engines.

The XML site map normally contains the following XML nodes

  • url

    • loc - the url of the page

    • lastmod - the modified date

    • changefreq - how often page is updated

    • priority - how important in your website is this page (0.0 - 1.0)






The url node need to be repeated for each link on your website.

Don't worry if it looks scary there are lots of good resources online to create your own XML website / sitemap.

But a simple search will help you find lots of great sitemap creators, so you don't need to be scared.

  • Text Based - This is a text based version of your sitemap

The text sitemap is just a simple list of your links on your website

For Example


http://www.buzzproperties.co.uk/
http://buzzproperties.co.uk/




Now I have my sitemap what do I do with it

  • Simply save each file with any name you like
  • upload the file to your website root i.e http://buzzproperties.co.uk/sitemap.xml
  • Register for Google Webmaster Tools at https://www.google.com/webmasters/tools
  • Login to your webmaster tools account
  • Add your website url into the add site box
  • Click on your website in the list and click on Sitemaps on the left menu
  • Click add a sitemap and enter the url of the sitemap on your website (your can add both the text and XMl sitemap to your listing)

Google will validate your sitemaps and if everything is OK it will let you know in the status.

Google now knows about your sitemap, and everytime you make changes just update your sitemap and upload, and resubmit it - that is unless none of the links have changed.



Thanks
Sean J Connolly
Visit AJAX Web Development Store

Follow me on Twitter - http://twitter.com/seanjc

Find me on MySpace - http://www.myspace.com/seanjc
Find me on FaceBook - http://www.facebook.com/profile.php?id=567767993


DMS - Document Management, Webmail
BuzzProperties.co.uk - Online Property Sales and Letting