Timelog とは
Timelog はいわゆるミニブログのWebサービス。
一時期、サービス終了が告知されたが、他の会社が運営を引き継いで復活した。
現在は、活発にメンテされているようには見えないが、低空飛行ながら運営が続けられている。
近い将来、リニューアルする可能性もあるという。
[ヅ] ミニブログの Timelog が復活していた (∩´∀`)∩ワーイ (2014-04-09)
Timelog API のドキュメント
Timelog API のドキュメントはもう公式サイトに残っていないので、 Internet Archive の過去のスナップショットを参考にする。
機能:自分の発言を取得する
URL:http://api.timelog.jp/my_msg.asp
認証:BASIC
パラメータ:
cnt : 取得件数 [10-50] default:10
fmt : 取得形式 [ xml , rss , json , atom , ical] default:xml
jsonp : fmtがjson時、ここで指定した名前を返します
stat : 取得条件 [bm:Bookmark , td:ToDo , gn:Good&New , ca:集計 , jd:投票 , rv:Review ] default:DM以外全て
since : 指定日の発言を取得します[since=20070530]記号無しでお願いします
自分のメモIDを指定した場合は、指定したID以降の発言を取得します
tag : タグで絞り込みをする場合に指定します
hc : 1を指定すれば評価(☆)の数も取得できます default:0
注:並び順は通常では時間での降順ですが、since指定がある場合のみ昇順になります
ical(iCalendar)形式はGoogleCalendarでのみテストしてあります
例:http://api.timelog.jp/my_msg.asp?cnt=20&stat=bm&since=20070530
今をメモする「Timelog」
以前は、fmt=xml がデフォルトだったが、ひさびさにAPIをコールしてみたら fmt=json がデフォルトになっていた(ドキュメントは無い)。
Ruby によるサンプルコード
ソースコード。
require 'net/http'
require 'uri'
class TimelogAPI
def initialize(account, password)
@account = account
@password = password
end
def my_msg(params)
url = 'http://api.timelog.jp/my_msg.asp'
url += '?' + URI.encode_www_form(params) if params != nil
uri = URI.parse(url)
http = Net::HTTP.new(uri.host, uri.port)
req = Net::HTTP::Get.new(uri.request_uri)
req.basic_auth(@account, @password)
res = http.start do |h|
h.request(req)
end
res.body
end
end
account = '<YOUR ACCOUNT>'
password = '<YOUR PASSWORD>'
timelog = TimelogAPI.new(account, password)
puts timelog.my_msg({'hc' => '1', 'since' => '20170129', 'fmt' => 'xml'})
puts timelog.my_msg({'hc' => '1', 'since' => '20170129'})
サンプルコードの実行結果。
<?xml version="1.0" encoding="UTF-8"?>
<memos>
<title>TimeLog finearc</title>
<link rel="alternate" type="text/html" href="http://timelog.jp"/>
<modified>2017/02/20 19:33:12</modified>
<author>
<id>nilab</id>
<name>nilab</name>
<image>
<normal>http://img.timelog.jp/imageuserface/nilab.jpg</normal>
<thumb>http://img.timelog.jp/imageuserface/nilab_m.jpg</thumb>
<small>http://img.timelog.jp/imageuserface/nilab_s.jpg</small>
</image>
</author>
<entry>
<id>b16be0a4d17f40a558856a0443f2cf089047d09a65de20</id>
<dispflag>0</dispflag>
<memo>(。・・)ノ </memo>
<toid></toid>
<toname></toname>
<tododate></tododate>
<replyid></replyid>
<tag></tag>
<author>
<id>nilab</id>
<name>nilab</name>
<statflag>1</statflag>
<image>
<normal>http://img.timelog.jp/imageuserface/nilab.jpg</normal>
<thumb>http://img.timelog.jp/imageuserface/nilab_m.jpg</thumb>
<small>http://img.timelog.jp/imageuserface/nilab_s.jpg</small>
</image>
</author>
<link rel="alternate" type="text/html" href="http://timelog.jp/msg/?b16be0a4d17f40a558856a0443f2cf089047d09a65de20"/>
<modified>2017/01/29 08:03:30</modified>
<star>6</star>
</entry>
</memos>
{"timelog":[
{
"id":"nilab",
"dispflag":"0",
"statflag":"1",
"name":"nilab",
"msg":"(。・・)ノ ",
"toid":"",
"toname":"",
"tododate":"",
"msgid":"b16be0a4d17f40a558856a0443f2cf089047d09a65de20",
"replyid":"",
"url":"http://timelog.jp/msg/?b16be0a4d17f40a558856a0443f2cf089047d09a65de20",
"tag":"",
"date":"2017-01-29T08:03:30+09:00",
"star":"",
"imagen":"http://img.timelog.jp/imageuserface/nilab.jpg",
"imagem":"http://img.timelog.jp/imageuserface/nilab_m.jpg",
"images":"http://img.timelog.jp/imageuserface/nilab_s.jpg"
}
]}
tags: timelog webapi ruby
Posted by NI-Lab. (@nilab)