Google Feed API JavaScript reference
Constructor
| Constructor | Description |
|---|---|
|
Instances of the
Basic applications load the feed using the |
Methods
| Method | Description |
|---|---|
|
|
|
|
|
|
|
If used in conjunction with a PubSubHubbub-enabled feed, this method allows you to load feed updates when the page loads, within a few minutes of publication.
Since including historical entries increases the number of returned feed entries, most developers combine this method with
|
|
|
|
|
|
|
|
|
|
Static method
Result objects
Basic
The .load() method calls the function argument with a single result when the feed download completes. The result has the following structure:
-
<root>
-
error?Present if there was an error loading the feed.-
code -
messageA human-readable string describing the error.
-
-
xmlDocument?The feed XML document. Present for theXML_FORMATandMIXED_FORMATresult formats. See the XML documentation below. -
feed?The JSON representation of the feed. Present for theJSON_FORMATandMIXED_FORMATresult formats. See the JSON documentation below.
-
JSON
If you request the google.feeds.Feed.JSON_FORMAT result format, the feed attribute appears in the feed result. It corresponds to the json value for the output argument in JSON. The feed attribute has the following structure:
feed-
feedUrlThe URL for the feed.Note: This API uses URL normalization to standardize feed URLs. Therefore, the API does not always return the same URL that you supplied. The
contextparameter allows you to distinguish between multiple feed load requests. -
title -
link -
descriptionThe feed description. Corresponds to the <subtitle> element in Atom and the <description> element in RSS. -
authorThe feed author. Corresponds to the <name> element for the author in Atom. -
entries[]A list of all of the entries in the feed. Corresponds to the <entry> element in Atom and the <item> element in RSS.-
mediaGroupA container for Media RSS feed results. All result properties nested undermediaGroupscorrespond exactly as documented in the Media RSS Specification. Media RSS is available only for feed entries newer than February 1st, 2010. Please refer to that specification for detailed information about Media RSS fields. -
title -
link -
contentThe body of this entry, inlcuding HTML tags. Since this value can contain HTML tags, you should display this value usingelem.innerHTML = entry.content(as opposed to usingdocument.createTextNode). Corresponds to the <content> or <summary> elements in Atom and the <description> element in RSS. -
contentSnippetA snippet (< 120 characters) version of thecontentattribute. The snippet does not contain any HTML tags. -
publishedDateThe string date on which the entry was published of the form "13 Apr 2007 12:40:07 -0700". You can parse the date withnew Date(entry.publishedDate). Corresponds to the <published> element in Atom and the <pubDate> element in RSS. -
categories[]A list of string tags for the entry. Corresponds to the term attribute for the <category> element in Atom and the <category> element in RSS.
-
-
XML
If you request the google.feeds.Feed.XML_FORMAT result format, the API places the xmlDocument attribute in the feed result. This attribute is the fully parsed XML Document node for the feed. It corresponds to the xml value for the output argument in JSON. You can access the document using the XML functionality built into browsers (e.g., getElementsByTagName).
Mixed
If you request the google.feeds.Feed.MIXED_FORMAT result format, the API places both the feed JSON attribute and the xmlDocument XML DOM attribute in the feed result. It corresponds to the json_xml value for the output argument in JSON. See the JSON result format and XML result format for details.
In addition to those attributes, every entry in the JSON results array contains an additional xmlNode property. That property is a pointer to the XML Element representing that entry in the feed XML document. For an ATOM feed, xmlNode points to the <entry> element for the entry. For an RSS feed, xmlNode points to the <item> element for the entry.
FindResult
The findFeeds() method calls the callback function argument with a single result when the feed query completes. The result has the following structure:
- <root>
-
error?Present if there was an error loading the feed.-
code -
messageA human-readable string describing the error.
-
-
entries[]A list typically containing up to ten feeds that matched the given query string.-
titleThe feed title. -
linkThe URL for the HTML version of the feed. -
contentSnippetA snippet (< 120 characters) version of the content. -
urlThe URL for the actual feed.
-
-
Troubleshooting
If you encounter problems:
- Look for typos. Remember that JavaScript is a case-sensitive language.
- Use a JavaScript debugger. Google Chrome has a full set of developer tools. In Firefox, you can use the JavaScript console or the Firebug. In IE, you can use the Microsoft Script Debugger.
- Search the discussion group. If you can't find a post that answers your question, post your question to the group along with a link to a web page that demonstrates the problem.