ネットサービスの開発に役立ちそうな話題を中心にお届けします。
F.Ko-Jiの「一秒後は未来」 > API > Twitter APIで「この発言に対するレス」が可能に
2008年08月17日 18:33
1265日前に投稿

Twitter APIで「この発言に対するレス」が可能に

  • ... PV
  • このエントリーをはてなブックマークに追加

Twitter API の update メソッドに in_reply_to_status_id というパラメータが追加されているようなので、早速試してみました。

まずは普通に update してみます。

$ curl -u mail:password -d status="test" http://twitter.com/statuses/update.xml

XMLのレスポンスは以下の通り。

<?xml version="1.0" encoding="UTF-8"?>
<status>
  <created_at>Sun Aug 17 09:16:43 +0000 2008</created_at>
  <id>890078911</id>
  <text>test</text>
  <source>web</source>
  <truncated>false</truncated>
  <in_reply_to_status_id></in_reply_to_status_id>
  <in_reply_to_user_id></in_reply_to_user_id>
  <favorited></favorited>
  <user>
    <id>1622901</id>
    <name>$F.Ko-Ji</name>
    <screen_name>fkoji</screen_name>
    <location>Japan</location>
    <description>Blogrammer</description>
    <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/29791462/hello-tedy_normal.jpg</profile_image_url>
    <url>http://blog.fkoji.com/</url>
    <protected>false</protected>
    <followers_count>348</followers_count>
  </user>
</status>

レスポンスの status 要素に <id>890078911</id> が含まれているので、この id に対してレスを投げてみます。

$ curl -u mail:password -d 'status="test"&in_reply_to_status_id=890078911' http://twitter.com/statuses/update.xml

このレスポンスは以下の通り。 in_reply_to_status_id という要素と in_reply_to_user_id という要素にそれぞれ id が設定されているので、誰のどの発言に対する投稿なのかがわかります。

<?xml version="1.0" encoding="UTF-8"?>
<status>
  <created_at>Sun Aug 17 09:18:14 +0000 2008</created_at>
  <id>890079524</id>
  <text>"test"</text>
  <source>web</source>
  <truncated>false</truncated>
  <in_reply_to_status_id>890078911</in_reply_to_status_id>
  <in_reply_to_user_id>1622901</in_reply_to_user_id>
  <favorited></favorited>
  <user>
    <id>1622901</id>
    <name>$F.Ko-Ji</name>
    <screen_name>fkoji</screen_name>
    <location>Japan</location>
    <description>Blogrammer</description>
    <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/29791462/hello-tedy_normal.jpg</profile_image_url>
    <url>http://blog.fkoji.com/</url>
    <protected>false</protected>
    <followers_count>348</followers_count>
  </user>
</status>

この投稿を実際のTwitterの画面で見てみると、 in reply to というリンクがついていて、どの発言に対するレスなのかが分かるようになっています。

twitter-in_reply_to_status_id.gif

以下の参考記事を見る限り、今のところAPI経由でしかこの機能は利用できないようです。

【参考】
» Twitter Adds Threaded Replies; Complicates Developers’ Lives
» API Documentation - Twitter Development Talk | Google グループ
» in_reply_to_status_id - Twitter Development Talk | Google グループ

スポンサード リンク

Written by
Meity.jp - Twitterなかまでプライベートなオフ会を開催したいなら


トラックバック

このエントリーのトラックバックURL:

API / Twitter(ツイッター)

English version

前のエントリー: « Blog Action Day 2008、今年のテーマは「貧困(poverty)」
次のエントリー: 松木里菜、金曜プレステージでヒロインへ(事件記者~警視庁記者クラブ~ | 2008-09-12) »

コピペにご利用ください。

タイトル:

URL:

リンク用HTMLタグ: