|
AjaxFeed
Atom and RSS 2.0 feeds can be obtained using jQuery.ajax. The jQuery.get and jQuery.getFeed shortcuts can also be used.
jQuery.ajax, jQuery.get, jQuery.getFeed en, ja Obtaining Atom FeedAtom feed can be obtained using jQuery.ajax. At this point, specify feeds' URL to url and feed to dataType. $.ajax({
url: 'http://rss.rssad.jp/rss/gihyo/feed/atom',
data: {},
dataType: 'feed',
success: function(feed) {
console.info(feed.URL);
console.info(feed.Link);
console.info(feed.Title);
console.info(feed.Description);
console.info(feed.Author);
$.each(feed.Entry, function(i, entry) {
console.info(entry.Link);
console.info(entry.Title);
// console.info(entry.Summary);
console.info(entry.Date);
var date = new Date();
date.setTime(entry.Date);
console.info(date.toLocaleString());
});
},
error: function(xhr, status, e) {
console.info(xhr, status, e);
}
});This can also be done using jQuery.get $.get('http://rss.rssad.jp/rss/gihyo/feed/atom', {}, function(feed) {}, 'feed');The same can be done using jQuery.getFeed $.getFeed('http://rss.rssad.jp/rss/gihyo/feed/atom', {}, function(feed) {});Obtain an RSS 2.0 FeedRSS 2.0 feed can be obtained using jQuery.ajax. At this point, specify feeds' URL to url and feed to dataType. $.ajax({
url: 'http://rss.rssad.jp/rss/gihyo/feed/rss2',
data: {},
dataType: 'feed',
success: function(feed) {
console.info(feed.URL);
console.info(feed.Link);
console.info(feed.Title);
console.info(feed.Description);
console.info(feed.Author);
$.each(feed.Entry, function(i, entry) {
console.info(entry.Link);
console.info(entry.Title);
// console.info(entry.Summary);
console.info(entry.Date);
var date = new Date();
date.setTime(entry.Date);
console.info(date.toLocaleString());
});
},
error: function(xhr, status, e) {
console.info(xhr, status, e);
}
});This can also be done using jQuery.get $.get('http://rss.rssad.jp/rss/gihyo/feed/rss2', {}, function(feed) {}, 'feed');The same can be done using jQuery.getFeed $.getFeed('http://rss.rssad.jp/rss/gihyo/feed/rss2', {}, function(feed) {});Feed structure and itemsEven if the format of feed for the Atom, RSS 2.0, etc., are different, the structure and the items of the obtained feed remain the same.
| ||||||||||||||||||||||
► Sign in to add a comment
はじめまして。長瀬です。 Partuzaの場合、Dateプロパティーは秒数なので、 var date = new Date(entry.Date*1000); としないとだめですね。
ほかのコンテナはわかりませんが。
失礼しました。
なかじまんです。コメントありがとうございます。Partuza だと Shindig は PHP 版ですね。iGoogle や Orkut は ms 単位になっています。なので、Shindig PHP 側で対応すべきものでしょう。周りの識者にも聞いてみますね。
Shindig Java はミリ秒単位、Shindig PHP (Patruza) は秒単位というのが現状です。opensocial-jquery では Shindig PHP のとき、内部でミリ秒単位に変換できないか検討してみます。できるかな?
Patruza (Shindig PHP) は秒単位の件、0.5.1 で対応しました。32bit(2^32)未満のときは秒表現であるとみなして×1000しています。1970年の1月や2月だと誤認することになりますが、そのようなエントリの日時はありえないという妥協が条件です。