2008/01/31


先日ようやくPownceのAPIが公開されました。
APIはGoogle Groupで公開されています。
また、Python, Perl, ColdFusionを使ったライブラリも公開されています。ただし07/31時点では...
  • ColdFusionのディレクトリは空っぽ
  • PerlはMessageとFileしか対応していない
  • Pythonは全て対応しているけども中身が×××
って事で、MixiAPI.pyのようなものを作ってみました。
フィードの取得はPownceAPI.Session(userid, passwd)でセッションオブジェクトを作成し、get_notes()でfeedparserオブジェクトが返ります。また、ポストは
  • PownceAPI.Message(message)
  • PownceAPI.Link(message, url)
  • PownceAPI.File(message, file)
  • PownceAPI.Event(message, location, name, datetime)
で作成したオブジェクトをsession.send_item(to, item)で送信します。
簡単な例を以下に示します。
import PownceAPI

# セッションを作成
session = PownceAPI.Session("example""password")

# フィードを取得
print session.get_notes().entries[0].summary

# メッセージを送信
item = PownceAPI.Message("do you have a time?")
session.send_item("public", item)

# ファイルを送信
item = PownceAPI.File("my location""map.png")
session.send_item("all", item)

# リンクを送信
item = PownceAPI.Link("gugure!""http://www.google.com/")
session.send_item("public", item)

# イベントを送信
item = PownceAPI.Event("this is a party!""My Home""Yakiniku")
session.send_item("all", item)

今のところ、send_itemで指定出来るtoに制限があるのか、File等をallではなくpublicで送信すると500 Internal Server Errorが発生します。
また、APIを使ってもマルチバイト文字は表示されません。
とりあえず、動いている...といったところです。
もしPownceが使いたいが招待状がないという方は、コメントなりで連絡下さい。招待状を送らせて頂きます。

続きを読む...

Posted at by




お星様。ごめんね。

「このメッセージは最初の☆が付けられた際に消えます。」が消えないから...

自分のサイトに、はてなスターがカウントされないから...

はてなに問い合わせを出したら
「消えます。」のメッセージが消えると共に

なくなっちゃった。

lost_hatena_star

僕の心の中には、そして個別の記事にはちゃんといるから...

お星様。ごめんね。
Posted at by




はてなのお気に入りユーザーの情報を取得できる「お気に入りAPI」(Favorites API)を公開しました」って事でさっそく...


ソースはこんな感じ...
追記:このソースはFirefoxでしか動きません。IEで動くものはこのページのHTMLを直接参照下さい。(Firefox限定時の残骸あり) <script type="text/javascript">
<!--
function hatenaFavorites(data) {
  var container = document.getElementById('hatenaFavorites');
  Array.slice(container.childNodes).forEach(container.removeChild, container);
  data.favorites.forEach(function(i) {
    var div = document.createElement('div');
    var img = document.createElement('img');
    img.src='http://www.hatena.ne.jp/users/'+i.name.substring(0,2)+'/'+i.name+'/profile_s.gif'
    div.appendChild(img);
    div.appendChild(document.createTextNode(' ' + i.name));
    container.appendChild(div);
  });
}
function loadHatenaFavorites() {
  var container = document.getElementById('hatenaFavorites');
  Array.slice(container.childNodes).forEach(container.removeChild, container);

  var img = document.createElement('img');
  img.src='http://mattn.kaoriya.net/images/ajax-loader.gif';
  container.appendChild(img);

  var script = document.createElement('script');
  script.charset = 'utf-8';
  script.src = 'http://www.hatena.ne.jp/mattn/favorites.json?callback=hatenaFavorites';
  document.lastChild.appendChild(script);
}
--></script>

追記
os0xさんからの指摘でIEで動かないのを直しました。
↑のソースは張り替えませんので、直接ソースを閲覧して下さい。(残骸が残ってますが...)
Posted at by