My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
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
Updated Feb 6, 2010 by nakajim...@gmail.com

Obtaining Atom Feed

Atom 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 Feed

RSS 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 items

Even 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.

Feed Feed object
Feed.URL URL of the feed itself
Feed.Link Feed URL
Feed.Title Title of the feed
Feed.Description An explanation of the feed
Feed.Author Author of the feed
Feed.Entry Entry object
Feed.Entry.Link URL of a particular entry
Feed.Entry.Title Title of an entry
Feed.Entry.Summary Summary of an entry
Feed.Entry.Date Time/date of an entry (UNIX TIMESTAMP ms)

Comment by atsn....@gmail.com, Feb 8, 2009

はじめまして。長瀬です。 Partuzaの場合、Dateプロパティーは秒数なので、 var date = new Date(entry.Date*1000); としないとだめですね。

ほかのコンテナはわかりませんが。

失礼しました。

Comment by project member nakajim...@gmail.com, Feb 9, 2009

なかじまんです。コメントありがとうございます。Partuza だと Shindig は PHP 版ですね。iGoogle や Orkut は ms 単位になっています。なので、Shindig PHP 側で対応すべきものでしょう。周りの識者にも聞いてみますね。

Comment by project member nakajim...@gmail.com, Feb 9, 2009

Shindig Java はミリ秒単位、Shindig PHP (Patruza) は秒単位というのが現状です。opensocial-jquery では Shindig PHP のとき、内部でミリ秒単位に変換できないか検討してみます。できるかな?

Comment by project member nakajim...@gmail.com, Feb 16, 2009

Patruza (Shindig PHP) は秒単位の件、0.5.1 で対応しました。32bit(2^32)未満のときは秒表現であるとみなして×1000しています。1970年の1月や2月だと誤認することになりますが、そのようなエントリの日時はありえないという妥協が条件です。


Sign in to add a comment
Powered by Google Project Hosting