2008/03/26

Recent entries from same category

  1. javascript v8エンジンでv8::Objectに内部的な値を格納する方法が分かった。 Hatena
  2. Google Chromeが使っているjavascript v8エンジンにTwitterにアクセス出来るクラスを作ってポストする。 Hatena
  3. 【速報】とりあえずjavascript v8エンジンのベンチマーク結果 Hatena
  4. Google Maps APIにIPから現在位置を取得するAPIが追加された。 Hatena
  5. 「XSLとjQuery/HTMLだけで作る、amazon最速検索」が動かなくなってたので直した Hatena

はてな
昨日kuさんが頑張って探してたのはなんだったんだろう...苦笑
朝起きたらAPIが出来てました。確か昨日「/api」にアクセスしても無かったのになぁ。
FriendFeed Blog: FriendFeed API: Extend and improve FriendFeed

We are very excited to announce the launch of the FriendFeed API, which enables developers to interact with the FriendFeed site programmatically. It's designed to make it possible for anyone to improve FriendFeed or integrate FriendFeed into other applications. You can develop a FriendFeed interface for a mobile phone, build a FriendFeed widget for your blog, or develop an application that makes it easy to post photos to your feed from your iPhone.

さっそく使ってみました。APIはJSON、XML、RSS、ATOMで提供されており、クライアントライブラリとしてPHPとpythonのライブラリが用意されています。
つまり、XMLフォーマットを使っているgtktwitterを改造してgtkfriendfeedなんて事も出来る訳ですね。
ApiDocumentation - friendfeed-api - Google Code
friendfeed-api - Google Code
twitterと同じくprivateでなければ認証無しでアクセス出来ます。
認証が必要な場合は、「remotekey」と呼ばれるアプリケーションキーを取得する必要があります。remotekeyは
FriendFeed - Remote Key
で取得出来ます。認証方法はBasic認証です。今日は認証を使わない例ですが、javascriptからjsonで私と、kuさんと、otsuneさんのフィードをミックス表示する例をサンプルとして上げておきます。
まずコード
<style type="text/css"><!--
#mattn_friendfeed {
    margin: 1em;
    font-family: Verdana;
    width: 400px;
}
#mattn_friendfeed a {
    color: blue;
}
.friendfeed-line {
    padding-bottom: 1em;
}
.friendfeed-link {
    font-size: small;
}
--></style>
<script type="text/javascript"><!--
function mattn_friendfeed_callback(data) {
    var container = document.createElement('div');
    for(var n = 0; n < data.entries.length; n++) {
        var user = document.createElement('a');
        var link = document.createElement('a');
        var line = document.createElement('div');
        var icon = document.createElement('img');
        var br = document.createElement('br');
        user.href = data.entries[n].user.profileUrl;
        link.className = 'friendfeed-link';
        link.href = data.entries[n].link;
        link.appendChild(document.createTextNode(link.href));
        icon.src = user.href + '/picture?size=small';
        icon.setAttribute('align', 'left');
        user.appendChild(icon);
        br.setAttribute('clear', 'all');
        line.className = 'friendfeed-line';
        line.appendChild(user);
        line.appendChild(document.createTextNode(' ' + data.entries[n].title + ' '));
        line.appendChild(document.createElement('br'));
        line.appendChild(link);
        line.appendChild(br);
        container.appendChild(line);
    }
    document.getElementById('mattn_friendfeed').innerHTML = container.innerHTML;
}
function show_mattn_friendfeed() {
    document.getElementById('mattn_friendfeed').innerHTML = '<img src="http://mattn.kaoriya.net/images/ajax-loader.gif">';
    var s = document.createElement('script');
    s.charset = 'utf-8';
    s.src = 'http://friendfeed.com/api/feed/user?nickname=mattn,otsune,ku0522&callback=mattn_friendfeed_callback';
    document.body.appendChild(s);
}
--></script>
<input type="button" value="mattnのfriendfeedエントリを表示" onclick="show_mattn_friendfeed();" />
<br />
<em>mattnと、ku0522さんと、otsuneさんのmix表示</em><br />
<div id="mattn_friendfeed"></div>

そして実行例

mattnと、ku0522さんと、otsuneさんのmix表示

WriteBacks

TrackBack ping me at
Post a comment

writeback message: Ready to post a comment.