On Jun 9, 12:10 pm, Matt Kruse <[email protected]> wrote:
> Have you written any kind of wrapper/converter from the object
> returned from the API call to the object format returned from the
> _IG_FetchFeedAsJSON call?
Well, I whipped this up as a replacement for the built-in
_IG_FetcFeedAsJSON call. Just include this in your page, and you can
continue using the function as you did before but it will use the AJAX
Feed API instead.
Plus:
1. You get the Author and Categories fields
2. The old API structure is super-imposed on the new structure, so you
have both! This adds a little processing over-head, but it allows you
to process the feed either using the old API _or_ the new one using
the same JSON structure.
I'm going to put this into may gadget and see how well it works.
function _IG_FetchFeedAsJSON(url,callback,num,summaries) {
var gurl = 'http://ajax.googleapis.com/ajax/services/feed/load?
v=1.0&num='+num+'&q=' + encodeURIComponent(url)+'&random='+ (+new
Date);
_IG_FetchContent(gurl,function(responseText) {
document.getElementById('content').innerHTML =
'<pre>'+responseText
+'</pre>';
var json = eval('('+responseText+')');
if (!json || !json.responseData || !json.responseData.feed || !
json.responseData.feed.entries || json.responseStatus!=200) {
json.ErrorMsg = json.responseDetails;
}
else {
var feed = json.responseData.feed;
json.URL=url;
json.Title=feed.title;
json.Description=feed.description;
json.Link=feed.link;
json.Author=feed.author;
json.Entries=[];
for (var i=0; i<feed.entries.length; i++) {
var entry = feed.entries[i];
var date = new Date(entry.publishedDate);
date = date?date.getTime():new Date();
json.Entries.push( {
Title:entry.title,
Link:entry.link,
Summary:entry.content,
Date:date,
Author:entry.author,
Categories:entry.categories
} );
}
}
callback(json);
});
}
Matt Kruse
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"iGoogle Developer Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Gadgets-API?hl=en
-~----------~----~----~----~------~----~------~--~---