For those of you who have been trying to build client-side GData mashups but have been thwarted by the same-origin policy, we have some good news for you: you can now get public Base, Blogger, and Calendar feeds as JSON! This means that you can start displaying GData in your web page with a little JavaScript.
Let's take a look at how this works -- start out by opening this URL in your browser (this is the GData feed for the Google Doodle calendar):
http://www.google.com/calendar/feeds/
c4o4i7m2lbamc4k26sc2vokh5g%40group.calendar.google.com/public/full
?orderby=starttime&alt=json-in-script&callback=handleJson
You should see something like this:handleJson({"version": "1.0","encoding": "UTF-8","feed"...});
What you are looking at is a JavaScript function named handleJson() that is being applied to a big JavaScript object. This object has a hierarchical structure that parallels that of the Atom representation of the feed (you can also read about the details on how the XML to JSON mapping works).
Using the following GET parameters in the URL:alt=json-in-script&callback=handleJson
tells the feed to return itself in JSON format wrapped in a function named handleJson. The alt type is called json-in-script because this is often useful in conjunction with a <script> tag.
<script>
function handleJson(json) {
alert("The title of the feed is: " + json.feed.title.$t);
}
</script>
<script src="http://www.google.com/calendar/feeds/
c4o4i7m2lbamc4k26sc2vokh5g%40group.calendar.google.com/
public/full?orderby=starttime&alt=json-in-script&callback
=handleJson"></script>
(you might need to fiddle with the linebreaks here)
When you load the above snippet of HTML in a web page, the following happens:
- The first script tag is loaded, defining a function called handleJson() in the global environment.
- The second script tag is loaded, which looks for a global handleJson() function, and then applies it to a big JavaScript object. If the order of the script tags were reversed, loading the GData URL would result in a JavaScript error because handleJson() would not have been defined yet.
- handleJson() pops up the title of the feed because json.feed.title.$t in the JSON representation maps to:
<feed>
<title>Google Doodles</title>
in the Atom representation.
Let us know when you have created some nifty JavaScript widgets for presenting GData on the web!
- Michael Bolin, Software Engineer

2 comments:
I would gold für wow cultivate courage.buy wow gold “Nothing is so mild wow gold cheap and gentle as courage, nothing so cruel and pitiless as cowardice,” syas a wise author. We too often borrow trouble, and anticipate that may never appear.”wow gold kaufen The fear of ill exceeds the ill we fear.” Dangers will arise in any career, but presence of mind will often conquer the worst of them. Be prepared for any fate, and there is no harm to be freared. If I were a boy again, I would look on the cheerful side. life is very much like a mirror:sell wow gold if you smile upon it,maple mesos I smiles back upon you; but if you frown and look doubtful on it,cheap maplestory mesos you will get a similar look in return. Inner sunshine warms not only the heart of the owner,world of warcraft power leveling but of all that come in contact with it. “ who shuts love out ,in turn shall be shut out from love.” If I were a boy again, I would school myself to say no more often.billig wow gold I might cheap mesos write pages maple meso on the importance of learning very early in life to gain that point where a young boy can stand erect, and decline doing an unworthy act because it is unworthy.wow powerleveling If I were a boy again, I would demand of myself more courtesy towards my companions and friends,wow leveling and indeed towards strangers as well.Maple Story Account The smallest courtesies along the rough roads of life are wow powerleveln like the little birds that sing to us all winter long, and make that season of ice and snow more endurable. Finally,maple story powerleveling instead of trying hard to be happy
Welcome to the warhammer gold, In here you can buy
the warhammer Online gold, Do you know that the warhammer money in the game is very important, If you
had more cheap warhammer Online gold . I think you can get the tall level, quickly come here to buy warhammer gold.
Post a Comment