<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>TECKpert &#187; GoogleBase</title>
	<atom:link href="http://www.teckpert.com/category/googlebase/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.teckpert.com</link>
	<description>Your web and software development experts</description>
	<lastBuildDate>Thu, 02 Sep 2010 22:33:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>TECKpert&#8217;s Tips: Using Google Base with .NET for Real Estate</title>
		<link>http://www.teckpert.com/real-estate-on-the-web/tips-googlebase-for-real-estate/</link>
		<comments>http://www.teckpert.com/real-estate-on-the-web/tips-googlebase-for-real-estate/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 15:41:03 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Coding Tips]]></category>
		<category><![CDATA[GoogleBase]]></category>
		<category><![CDATA[Real Estate]]></category>
		<category><![CDATA[.net for real estate]]></category>
		<category><![CDATA[agents]]></category>
		<category><![CDATA[google base]]></category>
		<category><![CDATA[google base for wordpress]]></category>
		<category><![CDATA[google base real estate api]]></category>
		<category><![CDATA[google base real estate feed]]></category>
		<category><![CDATA[google base real estate listings]]></category>
		<category><![CDATA[real estate]]></category>
		<category><![CDATA[wordpress idx]]></category>

		<guid isPermaLink="false">http://www.teckpert.com/?p=363</guid>
		<description><![CDATA[Adding listings to Google Base Real Estate is simple and completely free. Today I’ll show how to, using the Google Base .net library, add listings to Google Base and then search for those listings.]]></description>
			<content:encoded><![CDATA[<p>Adding listings to Google Base Real Estate is simple and completely free. Today I’ll show how to, using the Google Base .NET library, add listings to Google Base and then search for those listings. The library can be downloaded at <a href="http://code.google.com/apis/gdata/client-cs.html">http://code.google.com/apis/gdata/client-cs.html</a>.</p>
<p>First import the following classes from the Google Base Client library.</p>
<pre class="brush:csharp">using Google.GData.Client;

using Google.GData.GoogleBase;</pre>
<p>To insert items, you need to be authenticated. Specify your Google Base account name and password to GBaseService as follows. You can use your Gmail account but you have to first sign into Google Base to activate the account.</p>
<pre class="brush:csharp">GBaseService service = new GBaseService("Application Name", developerKey);

service.setUserCredentials("username", "password"); </pre>
<p>The next step is to create the GBaseEntry you would like to insert.</p>
<pre class="brush:csharp">GBaseEntry entry = new GBaseEntry();

entry.Title.Text = "My Title";

entry.Content.Content = description;</pre>
<p>It is important to set the ItemType to &#8220;Housing&#8221;.</p>
<pre class="brush:csharp">entry.GBaseAttributes.ItemType = "Housing"; </pre>
<p>Now set the other attributes. To see a list of all the Google Base attributes go to <a href="http://base.google.com/support/bin/answer.py?hl=en&amp;answer=78170">http://base.google.com/support/bin/answer.py?hl=en&amp;answer=78170</a>.</p>
<pre class="brush:csharp">FloatUnit unit = new FloatUnit(price, "usd");

entry.GBaseAttributes.Price = unit;

entry.GBaseAttributes.AddTextAttribute("feature", feature);

entry.GBaseAttributes.AddImageLink(imgLink);

entry.GBaseAttributes.AddTextAttribute("property_type", propertyType);

entry.GBaseAttributes.AddTextAttribute("listing_type", listType);

entry.GBaseAttributes.AddTextAttribute("listing_status", listStatus);

FloatUnit sunit = new FloatUnit(sqft, "square ft.");

entry.GBaseAttributes.AddFloatUnitAttribute("square_feet", sunit);

entry.GBaseAttributes.AddFloatAttribute("bathrooms", baths);

entry.GBaseAttributes.AddIntAttribute("bedrooms", beds);

entry.GBaseAttributes.Location = "Address, City, State xxxxx USA ";

entry.GBaseAttributes.AddTextAttribute("mls_listing_id", listingID);

entry.GBaseAttributes.AddTextAttribute("broker", listBroker);

entry.GBaseAttributes.AddTextAttribute("agent", listAgent); </pre>
<p>Finally, insert this GBaseEntry object into the Items feed.</p>
<pre class="brush:csharp"> GBaseEntry ent = service.Insert(GBaseUriFactory.Default.ItemsFeedUri, entry); </pre>
<p>The method <code>service.Insert</code> returns the item you just inserted. The Google Base server assigns pre-computed attributes for your entry such as the creation date and time, the author, and most importantly, the identifier (or URL) of the new entry. The entry may take a few hours to publish so it may not be searchable immediately.</p>
<p>Now you can search for your listings on Google Base by connecting to a snippets feed URL and then interpreting the resulting atom feed. This can be done programmatically by creating a GBaseService object and executing a query on it.</p>
<pre class="brush:csharp">GBaseService service = new GBaseService("Application Name", developerKey);

GBaseQuery query = new GBaseQuery(GBaseUriFactory.Default.SnippetsFeedUri); </pre>
<p>The following query will get single family homes for sale within a 5 mile radius of San Francisco CA.</p>
<pre class="brush:csharp">query.GoogleBaseQuery = @"[item type:housing] [listing type:for sale] [property_type:single] [location:@""San Francisco, CA, USA"" + 5mi]";</pre>
<p>You can also set the sort by and order, number of results, and search start index.</p>
<pre class="brush:csharp">query.NumberToRetrieve = 20;

query.StartIndex = 0;

query.AscendingOrder = true;

query.OrderBy = "price(float USD)";</pre>
<p>Lastly, execute the query and save the atom feed into a readable xml format. This can be parsed and displayed on a web page.</p>
<pre class="brush:csharp">XmlTextReader reader = new XmlTextReader(query.Uri.AbsoluteUri);

XmlDocument doc = new XmlDocument();

doc.Load(reader); </pre>
<p>Pretty simple right? Now you can have your listings searchable on Google along with your website.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.teckpert.com/real-estate-on-the-web/tips-googlebase-for-real-estate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
