Rocomotion pplog2 AtomAPI Spec

Rocomotion pplog2AtomAPIの実装についての解説です。
比べやすいかと思い、livedoorさんのソースを借りました。問題があれば書き直します。

ChangeLog
0.1: 2004/08/06 (UG)
Require Server Condition
[1] apache 1.XX.XX(1.3.29で確認)
[2] .htaccess使用可能
[3] mod_rewrite使用可能
[4] php4.3.0以上
http header

my credentials
X-WSSE: UsernameToken Username="name", PasswordDigest="digest", Nonce="nonce" , Created="timestamp"(順番遵守)

パスワード比較方法
[1] Nonceをbase64_decode
[2] sha1(Nonce . Created . Password)を16進数へ変換
[3] base64_encode([2])
[4] PasswordDigest と [3]を比較

Root Atom Endpoint

自分のBlogについて、service.post, service.feed, service.categories, service.uploadを返す。
Endpoint はhttp://***.com/pplog2/atomapi

Request

GET /atomapi
X-WSSE: my credentials

Response

200 OK
Content-Type: application/x.atom+xml

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://purl.org/atom/ns#">
  <link xmlns="http://purl.org/atom/ns#" type="application/x.atom+xml" rel="service.post" href="http://***.com/atomapi/blog_id=1" title="Blog Test"/>
  <link xmlns="http://purl.org/atom/ns#" type="application/x.atom+xml" rel="service.feed" href="http://***.com/atomapi/blog_id=1" title="Blog Test"/>
  <link xmlns="http://purl.org/atom/ns#" type="application/x.atom+xml" rel="service.categories" href="http://***.com/atomapi/blog_id=1/svc=categories" title="Blog Test"/>
  <link xmlns="http://purl.org/atom/ns#" type="application/x.atom+xml" rel="service.upload" href="http://***.com/atomapi/blog_id=1/svc=upload" title="Blog Test"/>
</feed>
Error
400 Bad Request
invalid password

GET FeedURI of Blog

entry の全件データを取得

Request

GET /atomapi/blog_id=1
X-WSSE: my credentials

Response

200 OK
Content-Type: application/x.atom+xml

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://purl.org/atom/ns#">
<link rel="alternate" type="text/html" href="http://***.com/pplog2/" />
<title>Blog Test</title>
<link rel="service.post" type="application/x.atom+xml" href="http://***.com/pplog2/atomapi/blog_id=1/entry_id=16" title="test"/>
<entry xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>test</title>
  <link rel="service.edit" type="application/x.atom+xml" href="http://***.com/pplog2/atomapi/blog_id=1/entry_id=16" title="test"/>
  <modified>Y-m-d\TH:i:s\Z</modified>
  <issued>Y-m-d\TH:i:s+09:00</issued>
  <id>tag:***.com/16.html</id>
  <summary>・・・</summary>
  <content type="text/html" mode="escaped" xml:lang="ja" xml:base="http://***.com/pplog2/">
  <![CDATA[
    ・・・
  
  </content>
  $lt;dc:subject>category</subject>
  <author>
  <name>UG</name>
  </author>
</entry>
<entry>
  ...
</entry>
</feed>
Error
400 Bad Request
invalid password

GET FeedURI of Blog

entry の指定件数分データを取得

Request

GET /atomapi/blog_id=1/entry_cnt=XXXXX
X-WSSE: my credentials

Response

200 OK
Content-Type: application/x.atom+xml

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://purl.org/atom/ns#">
<link rel="alternate" type="text/html" href="http://***.com/pplog2/" />
<title>Blog Test</title>
<link rel="service.post" type="application/x.atom+xml" href="http://***.com/pplog2/atomapi/blog_id=1/entry_id=16" title="test"/>
<entry xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>test</title>
  <link rel="service.edit" type="application/x.atom+xml" href="http://***.com/pplog2/atomapi/blog_id=1/entry_id=16" title="test"/>
  <modified>Y-m-d\TH:i:s\Z</modified>
  <issued>Y-m-d\TH:i:s+09:00</issued>
  <id>tag:***/16.html</id>
  <summary>・・・</summary>
  <content type="text/html" mode="escaped" xml:lang="ja" xml:base="http://***.com/pplog2/">
  <![CDATA[
    ・・・
  
  </content>
  $lt;dc:subject>category</subject>
  <author>
  <name>UG</name>
  </author>
</entry>
<entry>
  ...
</entry>
</feed>
Error
400 Bad Request
invalid password

GET FeedURI of Entry

entry の1件データを取得

Request

GET /atomapi/blog_id=1/entry_id=XXXXXXXXX
X-WSSE: my credentials

Response

200 OK
Content-Type: application/x.atom+xml

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://purl.org/atom/ns#">
<link rel="alternate" type="text/html" href="http://***.com/pplog2/" />
<title>Blog Test</title>
<link rel="service.post" type="application/x.atom+xml" href="http://***.com/pplog2/atomapi/blog_id=1/entry_id=16" title="test"/>
<entry xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>test</title>
  <link rel="service.edit" type="application/x.atom+xml" href="http://***.com/pplog2/atomapi/blog_id=1/entry_id=16" title="test"/>
  <modified>Y-m-d\TH:i:s\Z</modified>
  <issued>Y-m-d\TH:i:s+09:00</issued>
  <id>tag:***.com/16.html</id>
  <summary>・・・</summary>
  <content type="text/html" mode="escaped" xml:lang="ja" xml:base="http://***.com/pplog2/">
  <![CDATA[
    ・・・
  
  </content>
  $lt;dc:subject>category</subject>
  <author>
  <name>UG</name>
  </author>
</entry>
</feed>
Error
400 Bad Request
invalid password

PostURI

エントリーを作成し 201 Created を返す。 レスポンスの Location: には service.edit が入る。

Request

POST /atomapi/blog_id=1
X-WSSE: my credentials

<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Go to Rocomotion</title>
  <dc:subject>Vacation</dc:subject>
  <content type="application/xhtml+xml" mode="xml">・・・</content>
</entry>

Response

201 Created
Content-Type: application/x.atom+xml
Location: http://***.com/pplog2/atomapi/blog_id=1/entry_id=XXXX

<?xml version="1.0" encoding="UTF-8" ?>
<entry xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
<title>Test</title>
<link rel="alternate" type="text/html" href="http://***.com/pplog2/17.html" />
<link rel="service.edit" type="application/x.atom+xml" href="http://***.com/pplog2/atomapi/blog_id=1/entry_id=17" title="Test" />
  <modified>2004-04-26T12:20:40Z</modified>
  <issued>2004-04-26T21:20:40+09:00</issued>
  <id>tag:***.com/pplog2/displog/17.html</id>
  <summary type="text/plain">・・・</summary>
  <content type="text/html" mode="escaped" xml:lang="ja" xml:base="http://***.com/pplog2/">
  <![CDATA[
  ・・・
  
  </content>
  $lt;dc:subject>category</subject>
  <author>
  <name>UG</name>
  </author>
</entry>
Error
400 Bad Request
invalid password

EditURI

投稿したentryを修正する

Request

PUT /atomapi/blog_id=1/entry_id=XXXX
X-WSSE: my credentials

<entry xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title xmlns="http://purl.org/atom/ns#">Test</title>
  <dc:subject>Vacation</dc:subject>
  <content xmlns="http://purl.org/atom/ns#" mode="xml">・・・</content>
</entry>

Response

200 OK
Error
400 Bad Request
invalid password

Delete EditURI

投稿したentryを削除する

Request

DELETE /atomapi/blog_id=1/entry_id=XXXXX
X-WSSE: my credentials

Response

200 OK
Error
400 Bad Request
invalid Password

Categories FeedURI

カテゴリ一覧を取得する実験的API。正式な仕様ではないため SixApart の名前空間を使用。

Request

GET /atomapi/blog_id=XXXX/svc=categories
X-WSSE: my credentials

Response

200 OK
Content-Type: application/x.atom+xml
<?xml version="1.0" encoding="utf-8"?>
<categories xmlns="http://sixapart.com/atom/category#">
  <subject xmlns="http://purl.org/dc/elements/1.1/">A</subject>
  <subject xmlns="http://purl.org/dc/elements/1.1/">B</subject>
  <subject xmlns="http://purl.org/dc/elements/1.1/">C</subject>
</categories>
Error
400 Bad Request
invalid Password

Fileupload PostURI

画像をアップロードする。

Request

POST /atomapi/blog_id=1/svc=upload
X-WSSE: my credentials

<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://purl.org/atom/ns#">
  <title xmlns="http://purl.org/atom/ns#">filename.jpg</title>
  <content xmlns="http://purl.org/atom/ns#" mode="base64">・・・</content>
</entry>

Response

200 OK
Content-Type: application/x.atom+xml
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://purl.org/atom/ns#">
  <link rel="alternate" type="image/jpeg" href="http://***.com/pplog2/sam/t-123456.jpg" />
</feed>
Error
400 Bad Request
invalid Password

References