Google Base

5 posts by 2 authors in: Forums > CMS Builder
Last Post: January 18, 2010   (RSS)

By richc - January 18, 2010

Has anyone used Google Base to submit real estate feeds to Google Maps?

See http://maps.google.com.au/help/maps/realestate/data_provider_faq.html

Basically need to create an XML file and either have it updated daily or triggered to update when a new listing is added.

Thanks!

Re: [richc] Google Base

By Chris - January 18, 2010

Hi richc,

While I haven't used this service before, I can help get you started.

Firstly, you'll want to find a sample of the XML you'll want to generate. I found one here: http://base.google.com/base/intl/en_au/rss-v2.xml

I took that code and threw a foreach around one of the <item> tags, (removing the other <item> tags,) then pasted in a STEP 1 from using the CMSB Code Generator to make a listings page. After replacing some of the example content from the original <item> tags with code to output fields from CMSB, I ended up with this:

<?php header('Content-type: application/xml; charset=utf-8'); ?>
<?php

require_once "C:/wamp/www/CMSB-TRUNK/cmsAdmin/lib/viewer_functions.php";

list($listingsRecords, $listingsMetaData) = getRecords(array(
'tableName' => 'listings',
));

?>
<rss version ="2.0" xmlns:g="http://base.google.com/ns/1.0">
<channel>
<title>Sample RSS v2.0 AU Real Estate feed</title>
<description>A description of your content.</description>
<link>http://www.realestateautest.example.com</link>

<?php foreach ($listingsRecords as $record): ?>

<item>
<title><?php echo htmlspecialchars($record['title']) ?></title>
<g:bathrooms><?php echo htmlspecialchars($record['bathrooms']) ?></g:bathrooms>
<g:bedrooms><?php echo htmlspecialchars($record['bedrooms']) ?></g:bedrooms>

<g:item_type>Housing</g:item_type>
<description><?php echo htmlspecialchars($record['content']) ?></description>
<link rel="alternate" type="text/html" href="<?php echo htmlspecialchars($record['_link']) ?>"/>
<g:price><?php echo htmlspecialchars($record['price']) ?></g:price>
<g:price_type>negotiable</g:price_type>
<g:property_type>house</g:property_type>

<g:listing_type>residential for sale</g:listing_type>
</item>

<?php endforeach ?>

</channel>
</rss>


Note that you'll need to change the filepath to viewer_functions.php (in red above, you can find yours at the top of any viewer page you've generated.) You'll likely also need to change the field names (also in red above) to match your own section.

The above feed only includes the "Required" fields. Once you have that working, you can start adding the "Recommended" and "Optional" fields listed at http://base.google.com/support/bin/answer.py?answer=66779&hl=en_AU .

I hope this helps! Please let me know if you have any questions.
All the best,
Chris

Re: [chris] Google Base

By richc - January 18, 2010

Thanks Chris

It seems that I have to actually write that output to a separate XML file - strangely Google doesn't seem to accept a php file as the input.

Re: [chris] Google Base

By richc - January 18, 2010

Thanks for the quick response Chris!

I'm already using that method ( eg rss.xml.php) successfully for rss feeds and google map input ... my site is www.hawkes-bay.co.nz

Strangely though Google base seems to specify that an xml extension must be used - see http://base.google.com/support/bin/answer.py?answer=59542&hl=en_GB

However I will try to register a .php datafeed and see what happens...