http://code.google.com/intl/ja/apis/ajaxfeeds/documentation/
JavaScriptã®ã¿ã§ä»ã®ãµã¤ãã®æ
å ±ãåå¾ããå ´åãXmlHttpRequestãªãã¸ã§ã¯ãã¯ã¯ãã¹ãã¡ã¤ã³ã許å¯ããªããããJSONPãå©ç¨ãã¦åå¾ããã®ãåºæ¬ã§ããã
æ¬æ¥ãªãJSONPãå©ç¨ããããã«ã¯ããµã¼ãå´ãJSONPã«å¯¾å¿ããAPIãæã£ã¦ããããRSSãJSONPã«å¤æããä½æ¥ãå¿
è¦ã§ãããããããGoogleãå
¬éãã¦ããGoogle Ajax Feed API ã¨ããAPIãå©ç¨ããã°ãJSONPã®å¤æã»åå¾ãç°¡åã«æ±ããã
以ä¸ã«ãå
·ä½çã«ã¯ã©ã使ããã示ãã
Google Feed APIã®ã¿ãå©ç¨ããå ´å
<html><head> <script type="text/javascript" src="http://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("feeds", "1"); var rssFeedUrl = "http://weather.livedoor.com/forecast/rss/34/90.xml"; function initialize() { var feed = new google.feeds.Feed(rssFeedUrl); feed.load(function(result) { if (!result.error) { var container = document.getElementById("feed"); var html = ""; for (var i = 0; i < result.feed.entries.length; i++) { html += "<li>" + result.feed.entries[i].title; } container.innerHTML = html; } }); } window.onload = initialize; </script> </head> <body><div id="feed"></div></body> </html>
jQueryã¨ã®åããæ
<html><head> <script type="text/javascript" src="http://www.google.com/jsapi"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript"> google.load("feeds", "1"); var rssFeedUrl = "http://weather.livedoor.com/forecast/rss/34/90.xml"; // gFeed plugin : via http://yas-hummingbird.blogspot.com/2009/05/jquery-google-ajax-feed-api.html $.gFeed = function(url, options, callback){ var opt = $.extend({q: url, v: '1.0', num: 10}, options); if (!opt.q) return false; $.getJSON('http://ajax.googleapis.com/ajax/services/feed/load?callback=?', opt, function(data){ if (data) callback.call(this, data.responseData.feed); } ); } $(function() { $.gFeed(rssFeedUrl, {}, function(feed){ $(feed.entries).each(function() { $("#feed").append("<li>"+this.title); }); } ); }); </script> </head> <body><div id="feed"></div></body> </html>