Atom feed extensions for Google Data

Topics: Argotic.Extensions
Aug 7, 2008 at 7:20 PM
I am trying to write a small Contact Manager module for playing around with Google Contacts and I'm really impressed at to how Argotic handles atom feeds. I am a little lost on getting the extended elements from the feeds. A sample contact entry looks like this -

<entry>
    <id>http://www.google.com/m8/feeds/contacts/skylinetester%40gmail.com/base/0</id>
    <updated>2008-07-21T23:27:56.681Z</updated>
    <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contact" />
    <title type="text">Atom Tester</title>
    <link rel="http://schemas.google.com/contacts/2008/rel#edit-photo" type="image/*" href="http://www.google.com/m8/feeds/photos/media/atomtester%40gmail.com/0/1B2M2Y8AsgTpgAmY7PhCfg" />
    <link rel="self" type="application/atom+xml" href="http://www.google.com/m8/feeds/contacts/atomtester%40gmail.com/full/0" />
    <link rel="edit" type="application/atom+xml" href="http://www.google.com/m8/feeds/contacts/atomtester%40gmail.com/full/0/1216682876681000" />
    <gd:email rel="http://schemas.google.com/g/2005#other" address="atomtester@gmail.com" primary="true" />
  </entry>

Other contact information include phone numbers, addresses, etc and come in extended gd: tags. I did see an example on using ITunes extended feeds but am a bit clueless as to where I should start, for writing my own extension for Google data.

Any help/comments/suggestion would be great!
Coordinator
Aug 8, 2008 at 7:37 PM
You correct that you will need to write a custom syndication extension in order to consume and/or persist Google Data extension information in a syndication feed. The Google Data extension specification may be found at http://code.google.com/apis/gdata/elements.html. The XML namespace that will be used by the custom extension will be xmlns:gd=http://schemas.google.com/g/2005, and the default XML prefix will be gd.

I have not yet had time to write a Wiki entry describing the process of creating custom sysndication extensions, and so I apologize for the confusion. To create a custom syndication extension within the Argotic framework, you start by creating a class that inherits from the Argotic.Extensions.SyndicationExtension abstract base class. Within the default constructor of your custom class you will need to call the base SyndicationExtension(string xmlPrefix, string xmlNamespace, Version version, Uri documentation, string name, string description) constructor and provide the parameter values that map to your custom extension.

A good way to get started on writing custom syndication extensions is to take a look at the source code of the core extensions natively supported by the Argotic framework. The source code is included with the framework installer, and I would suggest looking at the BasicGeocodingSyndicationExtension extension in the Argotic.Extensions.Core namespace.

I will add a feature request to implement and support the Google Data extension for a future release. Please feel free to contact me directly if you have any questions after taking a look at how syndication extensions are implemented in the framework source code.

 

Feb 2, 2011 at 11:36 AM
Edited Feb 2, 2011 at 11:37 AM

Hi

I'm trying to do something similar, but instead of making an extension, I'm trying to find the extensions and the collect the data within.

I'm looking at a feed received by a Google Search API for Shopping query, bringing back a list of products. An example feed might be (some entries truncated):

<?xml version="1.0" encoding="UTF-8"?>
<feed gd:kind="shopping#products" gd:etag="&quot;SLO3SiyTPqTJi6N3OtRrdM3n4Ko/0TxmNee_K5BUVQfRPlvykx2AeZo&quot;" xmlns="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:s="http://www.google.com/shopping/api/schemas/2010">
<id>tag:google.com,2010:shopping/products</id>
<updated>2011-02-02T12:10:12.604Z</updated>
<title>Shopping Products</title>
<generator version="v1" uri="https://www.googleapis.com/shopping/search/">Search API for Shopping</generator>
<link rel="alternate" type="text/html" href="https://www.googleapis.com/shopping/search/"/>
<link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="https://www.googleapis.com/shopping/search/v1/public/products?alt=atom"/>
<link rel="self" type="application/atom+xml" href="https://www.googleapis.com/shopping/search/v1/public/products?country=GB&amp;q=mp3+player&amp;alt=atom&amp;rankBy=price:ascending&amp;maxResults=10&amp;startIndex=1"/>
<link rel="next" type="application/atom+xml" href="https://www.googleapis.com/shopping/search/v1/public/products?country=GB&amp;q=mp3+player&amp;alt=atom&amp;rankBy=price:ascending&amp;maxResults=10&amp;startIndex=11"/>
<link rel="previous" type="application/atom+xml"/>
<openSearch:totalResults>1261120</openSearch:totalResults>
<openSearch:startIndex>1</openSearch:startIndex>
<openSearch:itemsPerPage>10</openSearch:itemsPerPage>

<entry gd:kind="shopping#product">
<id>tag:google.com,2010:shopping/products/6459634/4235316865351194603</id>
<author>
<name>Play.com</name>
</author>
<published>2010-12-04T13:07:27.000Z</published>
<updated>2011-01-31T06:01:17.000Z</updated>
<title>i-nique GeeBee 4 In 1 MP3 Player Sports Armband / Large / Black</title>
<content type="text">&quot;The coolest looking arm band on the block - 3 months in developme...</content>
<link rel="alternate" type="text/html" href="http://www.play.com/Electronics/Electronics/4-/11307813/i-nique-GeeBee-4-In-1-MP3-Player-Sports-Armband-Large-Black/Product.html?_%24ja=tsid:11518%7Ccat:11307813%7Cprd:11307813"/>
<link rel="self" type="application/atom+xml" href="https://www.googleapis.com/shopping/search/v1/public/products/6459634/gid/4235316865351194603?alt=atom"/>
<s:product>
<s:googleId>4235316865351194603</s:googleId>
<s:author>
<s:name>Play.com</s:name>
<s:accountId>6459634</s:accountId>
</s:author>
<s:creationTime>2010-12-04T13:07:27.000Z</s:creationTime>
<s:modificationTime>2011-01-31T06:01:17.000Z</s:modificationTime>
<s:country>GB</s:country>
<s:language>en</s:language>
<s:title>i-nique GeeBee 4 In 1 MP3 Player Sports Armband / Large / Black</s:title>
<s:description>&quot;The coolest looking arm band on the...</s:description>
<s:link>http://www.play.com/Electronics/...</s:link>
<s:brand>Play.com</s:brand>
<s:condition>new</s:condition>
<s:gtin>05055205219523</s:gtin>
<s:inventories>
<s:inventory channel="online">
<s:price currency="GBP">3.75</s:price>
</s:inventory>
</s:inventories>
<s:images>
<s:image link="http://images.play.com/..."/>
</s:images>
</s:product>
</entry>

Now Argotic (and the MS Syndication lib) finds entries perfectly. The problem for both is when nested Extensions come into play - is it possible for Argotic to see these? The MS Syndication lib manages to find the <s:product> tag but it doesn't go down any deeper than that.
From what I've read, it would appear that the idea is to define a list of custom extension classes (seems a bit tedious but ok) then add these to the SyndicationResourcesLoadSettings.SupportedExtensions then load the feed with the settings, is this correct?

I've tried following your instructions and made the following constructor for the GExtension : SyndicationExtension class

public GExtension()
                : base("product", "http://www.w3.org/2005/Atom", new Version("1.0"), new Uri("http://code.google.com/apis/shopping/search/v1/reference-content-modules.html"),
                        "GoogleShoppingExtensions", "Extensions for displaying product data.")
            { }

then added the required method signatures, but I'm not entirely sure as to where to proceed afterwards.

I did:

 SyndicationResourceLoadSettings srls = new SyndicationResourceLoadSettings();
srls.SupportedExtensions.Add(typeof(GExtension));
srls.AutoDetectExtensions = true;
AtomFeed af = AtomFeed.Create(new Uri(uriStr), srls);

But it just brings up an extension collection when I examine it during debugging.