Friday, October 23, 2009

Google Dynamic Feed Control

This post is a test of the Google AJAX Feed API It's pretty much the sample code for a vertical stacked RSS feed display with two Amazon feeds. The only change I made to the style sheet was to assign background colors to elements where the blog's green canvas showed though. It could be made narrower to fit in a sidebar. See how to make your own slick feed control below this example:

Loading...

Instructions and code

To use the API, you must have a Google account and get your own API key, which is tied to your account and to your web site. Information, instructions and examples are available at Google AJAX API - Google Code. I chose a Vertical Stacked feed control with direct feed URLs, clicked Code Playground to get the foundation code, and edited it to include two Amazon RSS feeds.

The feed control includes three script tags. In the code shown below, I used a placeholder for my API key and Amazon affiliateID, and an underscore for a continuation symbol where there SHOULD NOT BE line breaks:

<script _
src="http://www.google.com/jsapi/?key=[yourAPIKey]" _
type="text/javascript"></script>
<script _
src="http://www.google.com/uds/solutions/ _
dynamicfeed/gfdynamicfeedcontrol.js" _
type="text/javascript"></script>
<script type="text/javascript">
google.load('feeds', '1');function OnLoad() _
{var feeds = [{title: 'Sci-fi - Fantasy',url: _
'http://www.amazon.com/rss/tag/sci-fi/popular? _ 
tag=yourTagID'},{title: _
'Bestsellers - Books',url: _
'http://www.amazon.com/rss/bestsellers/books? _ 
tag=yourTagID'}];var options = {stacked : true, horizontal : _ 
false,numResults : 10,title : "Amazon Popular Sci-fi _
Fantasy, Bestsellers"};new GFdynamicFeedControl(feeds, _ 
'GFeedDiv', options);}google.setOnLoadCallback(OnLoad);
</script>

To add the code to a blogger template, go to Layout, Page Elements, click Add a Gadget in the header and select HTML/JavaScript from the list of options. (If you have not enabled gadgets in your header, search for "blogger header add gadget" to find instructions.) You can leave the gadget at the top of the header, just below the navbar. You will add a div elsewhere in your template to display the feed control.

Add a link to Google's provided style sheet in the blog template. I put it in the <head> tag, below the <title>. Here is the code, with my overriding CSS:

<style type='text/css'>@import url("http://www.google.com/ _
uds/solutions/dynamicfeed/gfdynamicfeedcontrol.css");
.gfg-root {width: 98%;}
.gfg-root,.gfg-entry,.gfg-list, _
.gfg-horizontal-root .gfg-title {background: #FFFFFF;}
.gfg-title,.gfg-subtitle,.gfg-subtitle a:link, _
.gfg-subtitle a:visited {background:#7C9F2B; color:#FFFFFF;}
</style>

The feed control displays where you place a div with the id "GFeedDiv". The div is empty except for a span containing the text "Loading..."

<div id="GFeedDiv">
<span style="color:#676767;font-size:11px; margin:10px;
padding:4px;">Loading...</span></div>

To add the code to a post, you can simply paste it in HTML view. To add it to your template, go into Layout, Page Elements, and click Add a Gadget in the section where it should appear.

Wednesday, October 14, 2009

Simple Amazon RSS feed links

Amazon associates have easy, but limited, options for adding RSS feeds to their web sites:

  1. Several Amazon categories
  2. Feed URLs from customer tags newly assigned to product ASINs

Those who use the Product Advertising API have more ways to access data and create custom RSS feeds. There are tons of websites that offer Amazon feed generators based on the API, but I suspect that they add their own AssociateID to the feed URLs or get some revenue from acting as the aggregator. Caution is advised.

Note that the popular Gold Box feed of Daily Deals no longer works with an appended Associate ID. Consider using the Daily Deals widget, which provides the same functionality. If you must have the Gold Box feed, it works with the API or a Yahoo Pipe.

Adding feed links to your site is no different than adding other links. You could add a feed URL to your web page as a text link and as an image link, using the standard RSS feed icon or search Google to find alternative icons. Both types of links may be used together, as here:

Amazon Bestsellers

To add RSS feed LINKS to your blogger template, open the Layout tab and select Page Elements. Click "Add a gadget" in your sidebar and select HTML/Javascript from the list of gadget options. Paste the link, and change any ampersands (&) to &amp; and save it. You will need to drag the gadget where you want it to appear in the sidebar, preview, and save the layout change.

Adding RSS feed CONTENT to your blogger template is the same as adding links except that you should choose RSS from the gadget options.

RSS (or Atom) feeds usually consist of news items or other frequently updated information written as XML text files in a standard format. These days, most people would say that "RSS" stands for "Really Simple Syndication", referring to its purpose of syndicating or sharing news.

The XML files are often generated from database queries and reside on the server that offers the RSS feeds. An individual can also type a simple XML feed file in notepad and store it on a web server.

The RSS XML files use standard markup that can be formatted for readability by programs called "feed readers." A raw XML feed is just code and not very pleasant to read. It would be like trying to read a web page by viewing the source.

RSS feeds are proactive, in that a person chooses to subscribe to feeds of interest, and must have a way to read current news feeds using a feed reader. Before browsers had built-in feed readers, or Google Reader existed, a subscriber had to have a desktop feed reader program, access to a web-based service, such as Newsgator or Bloglines, or a hybrid, like Pluck.

These services (or even desktop programs) are called aggregators because they gather RSS news items from servers by visiting feed URLs to check for new items, usually at regular intervals throughout the day. Individuals can check for feed updates in their feedreader programs or by opening the web address of the feed in their browser.

Feeds can also be received as e-mail messages using a service like Feedburner.

Sunday, October 11, 2009

Disclosure Policy

Greene Teapot maintains an affiliate relationship with Amazon and displays contextual links by Google Adsense. I select Amazon links, but Google ads are determined solely by Google.

If a web visitor purchases an item from Amazon after going to the Amazon web site via an affiliate link on this site, I would receive a small commission. Some items, such as Kindle eBooks, are excluded from Amazon's affiliate program, and purchase does not result in payment.

Google pays a small amount for total page impressions and click-throughs.

No marketing e-mail is ever sent to visitors of this website.

No free review copies of books, media, or products are received through these relationships. Text or image links to selected books or other products available at Amazon may appear in some blog posts and may be featured in the blog sidebars. I base my selections on one of more of the following criteria:

  • I purchased the book for my personal library.
  • I am familiar with the author or publisher and trust the quality of their titles from personal experience.
  • I have searched for items on Amazon and have selected items that other customers review favorably.

This notice is posted in compliance with Federal Trade Commission Final Guidelines on Endorsements and Testimonials, October 5, 2009, which states:

"The notice incorporates several changes to the FTC’s Guides Concerning the Use of Endorsements and Testimonials in Advertising, which address endorsements by consumers, experts, organizations, and celebrities, as well as the disclosure of important connections between advertisers and endorsers. The Guides were last updated in 1980." (Italics added)

Affiliate links are swept into the definition of "endorsements" by this ruling, according to FTC Targets Affiliate Programs at All Things Digital. There is more information in Understanding the New FTC Guidelines at Blogging Basics 101.