SkyDriveのメディアファイルにアクセス
SkyDrive APIの3回目です。今回は、
SkyDriveのWebサイトでは、
![図1 フォルダーの種類 図1 フォルダーの種類](/assets/images/dev/serial/01/wl-sdk/0050/thumb/TH400_001.png)
アルバムは、
アルバムは、
Scopeの値 | 説明 |
---|---|
wl. |
SkyDriveのフォルダー・ |
wl. |
SkyDriveで共有されているフォルダー・ |
wl. |
SkyDriveのフォルダー・ |
上記のScopeよりもアクセスが制限されたScopeも用意されています。それが次のアルバムを対象とした読み取り専用のアクセスです。さらに、
Scopeの値 | 説明 |
---|---|
wl. |
SkyDriveのアルバムと写真・ |
wl. |
SkyDriveで共有されているアルバムと写真・ |
写真・
wl.
![図2 認可画面 図2 認可画面](/assets/images/dev/serial/01/wl-sdk/0050/thumb/TH800_002.png)
それでは、
- アルバム情報の取得
- アルバム情報の変更
- アルバムの作成
- アルバムの削除
- 写真、
ビデオ、 音楽情報の取得 - 写真、
ビデオ、 音楽情報の変更 - 写真、
ビデオ、 音楽のアップロード - 写真、
ビデオ、 音楽の削除 - タグ情報の取得
これらの操作は、
アルバム情報の取得
アルバムはフォルダーと同じ情報を持っています。SkyDrive直下のアルバム一覧を取得する場合、
- https://
apis. live. net/ v5. 0/ me/albums?access_ token=ACCESS_ TOKEN
URLにアクセスすると、
{
"data": [
{
"id": "folder.xxxxx",
"from": {
"name": "梓 中野",
"id": "xxxxx"
},
"name": "ビデオ",
"description": null,
"parent_id": "folder.XXXXX",
"count": 16,
"link": "https://skydrive.live.com/redir.aspx?cid...",
"type": "album",
"created_time": "2010-10-30T14:00:00+0000",
"updated_time": "2012-01-25T11:00:00+0000"
}
]
}
アルバムの情報を表すAlbumオブジェクトの内容は、
プロパティ | 型 | 説明 |
---|---|---|
data | array | Albumオブジェクトを含む配列 |
id | string | AlbumオブジェクトのID |
from | object | アルバム作成者の情報 |
name |
string | 作成者の名前 |
id |
string | 作成者のユーザーID |
name | string | アルバムの名前 |
description | stringまたはnull | アルバムの説明 |
count | number | アルバム内のアイテム数 |
link | string | SkyDriveでのアルバムのURL |
upload_ |
string | アプリから、 Scope 「wl. |
parent_ |
string | このアルバムの上位階層のリソースID |
type | string | オブジェクトの種類 アルバムの場合は、 |
created_ |
string | アルバムの作成日時 |
updated_ |
string | アルバム内のコンテンツの更新日時 |
shared_ |
object | アルバムの共有情報 Scope 「wl. |
access |
string | アルバムの共有情報 次の値のいずれか
|
フォルダーとアルバムでは、
アルバム情報を返すリソースのパスは次の通りです。あわせて第48回のフォルダー情報を返すリソースのパスも参照してください。
パス | 説明 |
---|---|
/ALBUM_ |
特定のアルバム |
/ALBUM_ |
特定のアルバム内のアイテム |
/me/ |
サインインユーザーのSkyDriveのルートにあるアルバム |
/me/ |
サインインユーザーのSkyDriveの共有フォルダー内のアルバム |
/USER_ |
特定のユーザーのSkyDriveのルートにあるアルバム |
アルバムの作成
アルバムを作成する場合は、
POST https://apis.live.net/v5.0/me/albums?access_token=ACCESS_TOKEN HTTP/1.1 Content-Type: application/json Host: apis.live.net Content-Length: 31 Connection: Keep-Alive {name: "新しいアルバム"}
写真情報の取得
次は、
{
"data": [
{
"id": "file.xxxxx",
"from": {
"name": "梓 中野",
"id": "xxxxx"
},
"name": "azusa.jpg",
"description": null,
"parent_id": "folder.XXXXX",
"size": 486730,
"comments_count": 0,
"comments_enabled": false,
"tags_count": 0,
"tags_enabled": true,
"picture": "http://storage.live.com/...",
"source": "http://storage.live.com/...",
"images": [
{
"height": 380,
"width": 800,
"source": "http://storage.live.com/...",
"type": "normal"
}, {
"height": 83,
"width": 176,
"source": "http://storage.live.com/...",
"type": "album"
}, {
"height": 45,
"width": 96,
"source": "http://storage.live.com/...",
"type": "thumbnail"
}, {
"height": 975,
"width": 2048,
"source": "http://storage.live.com/...",
"type": "full"
}
],
"link": "https://skydrive.live.com/redir.aspx?cid...",
"when_taken": null,
"height": 975,
"width": 2048,
"type": "photo",
"created_time": "2012-02-09T15:00:00+0000",
"updated_time": "2012-02-09T17:00:00+0000"
}
]
}
写真を表すPhotoオブジェクトの内容は次の通りです。Fileオブジェクトにはない項目は太字にしています。images配列からサムネイル画像を取得できます。また、
プロパティ | 型 | 説明 |
---|---|---|
data | array | Photoオブジェクトを含む配列 |
id | string | PhotoオブジェクトのID |
from | object | 作成者の情報 |
name |
string | 作成者の名前 |
id |
string | 作成者のユーザーID |
name | string | 写真のファイル名 |
description | string | 説明 |
parent_ |
string | この写真の上位階層のリソースID |
size | number | 写真のサイズ |
comments_ |
number | 写真に付けられたコメント数 |
comments_ |
true/ |
写真にコメント可能かどうか |
tags_ |
number | 写真に付けられたタグ数 |
tags_ |
true/ |
写真にタグ埋め込み可能かどうか |
picture | 写真のURL | |
source | string | 写真のダウンロード用のURL |
images | array | 異なる大きさの写真の情報 |
height |
number | 高さ |
width |
number | 幅(ピクセル) |
source |
string | 特定の大きさの写真のURL |
type |
string | 大きさの種類 次の値のいずれか
|
link | string | SkyDrive上での写真のURL |
upload_ |
string | アプリから写真をアップロードするためのURL Scope |
when_ |
string/ |
撮影日時 |
height | number | 高さ |
width | number | 幅(ピクセル) |
type | string | オブジェクトの種類 写真の場合は、 |
created_ |
string | 写真の作成日時 |
updated_ |
string | 写真の最終更新日時 |
shared_ |
object | 写真の共有情報 |
access |
string | 写真の共有情報 次の値のいずれか
|
Fileオブジェクトにあった、
![図3 写真の埋め込み 図3 写真の埋め込み](/assets/images/dev/serial/01/wl-sdk/0050/thumb/TH800_003.png)
また、
写真の表示
サムネイルやオリジナルの写真の表示は、
- https://
apis. live. net/ v5. 0/PHOTO_ ID /picture?type=thumbnail&access_token=ACCESS_ TOKEN
PHOTO_
写真のアップロード
アップロード方法は、
APIでは、
![図4 写真のアップロード 図4 写真のアップロード](/assets/images/dev/serial/01/wl-sdk/0050/thumb/TH800_004.png)
ビデオ情報の取得
次はビデオファイルです。ビデオファイルは、
{
"data": [
{
"id": "file.xxxxx",
"from": {
"name": "梓 中野",
"id": "xxxxx"
},
"name": "azusa.mp4",
"description": null,
"parent_id": "folder.XXXXX",
"size": 5819660,
"comments_count": 0,
"comments_enabled": false,
"tags_count": 0,
"tags_enabled": true,
"picture": "http://storage.live.com/...",
"source": "http://storage.live.com/...",
"link": "https://skydrive.live.com/redir.aspx?cid...",
"height": 360,
"width": 640,
"duration": 106138,
"bitrate": 310190,
"type": "video",
"created_time": "2012-02-09T15:11:00+0000",
"updated_time": "2012-02-09T15:12:00+0000"
}
]
}
ビデオを表すVideoオブジェクトの内容は次の通りです。Fileオブジェクトにはない項目は太字にしています。
プロパティ | 型 | 説明 |
---|---|---|
data | array | Videoオブジェクトを含む配列 |
id | string | VideoオブジェクトのID |
from | object | 作成者の情報 |
name |
string | 作成者の名前 |
id |
string | 作成者のユーザーID |
name | string | ビデオのファイル名 |
description | string | 説明 |
parent_ |
string | このビデオ上位階層のリソースID |
size | number | ビデオのサイズ |
comments_ |
number | ビデオに付けられたコメント数 |
comments_ |
true/ |
ビデオにコメント可能かどうか |
tags_ |
number | ビデオに付けられたタグ数 |
tags_ |
true/ |
ビデオにタグ埋め込み可能かどうか |
picture | ビデオを表す画像 |
|
source | string | ビデオのダウンロード用のURL |
link | string | SkyDrive上でのビデオのURL |
upload_ |
string | アプリからビデオをアップロードするためのURL Scope |
duration | number | ビデオの再生時間 |
bitrate | number | ビットレート |
type | string | オブジェクトの種類 ビデオの場合は、 |
created_ |
string | ビデオの作成日時 |
updated_ |
string | ビデオの最終更新日時 |
shared_ |
object | ビデオの共有情報 |
access |
string | ビデオの共有情報 次の値のいずれか
|
Photoオブジェクトと同じく、
音楽情報の取得
音楽ファイルは、
プロパティ | 型 | 説明 |
---|---|---|
data | array | Audioオブジェクトを含む配列 |
id | string | AudioオブジェクトのID |
from | object | 作成者の情報 |
name |
string | 作成者の名前 |
id |
string | 作成者のユーザーID |
link | string | SkyDrive上での音楽のURL |
name | string | 音楽のファイル名 |
description | string | 説明 |
parent_ |
string | このビデオ上位階層のリソースID |
size | number | 音楽のサイズ |
comments_ |
number | 音楽に付けられたコメント数 |
comments_ |
true/ |
音楽にコメント可能かどうか |
is_ |
true/ |
埋め込み用のHTMLコードを取得可能かどうか |
source | string | 音楽のダウンロード用のURL |
upload_ |
string | アプリからファイルをダウンロードするためのURL |
type | string | オブジェクトの種類 音楽の場合は、 |
created_ |
string | 音楽の作成日時 |
updated_ |
string | 音楽の最終更新日時 |
shared_ |
object | 音楽の共有情報 |
access |
string | 音楽の共有情報 次の値のいずれか
|
アップロードなどの操作も通常のファイルと同じです。ただし、
おわりに
今回はここまでです。いかがでしたでしょうか。メディアファイルの中でも写真については、