プロトコル ガイド

従来の Google Sites API を使用すると、アプリケーションで Google サイト内のコンテンツにアクセスしたり、コンテンツを公開したり、コンテンツを変更したりできます。また、アプリケーションは最近のアクティビティのリストをリクエストしたり、リビジョン履歴を取得したり、添付ファイルやファイルをアップロード/ダウンロードしたりできます。

オーディエンス

このドキュメントは、Google Data APIs プロトコルの背後にある一般的な概念を理解していることを前提としています。

このドキュメントは、Google サイトとやり取りできるクライアント アプリケーションを作成するプログラマーを対象としています。ここでは、生の XML/HTTP を使用した基本的なデータ API の操作例を説明付きで示します。このドキュメントを読んだ後、左側のナビバーにある他のガイドの言語固有の例を読むことで、クライアント ライブラリを使用して API を操作する方法について詳しく学ぶことができます。

このガイドの資料のリファレンスについては、リファレンス ガイドをご覧ください。

リクエストの承認

アプリケーションから非公開のユーザーデータがリクエストされた場合は、承認トークンを含める必要があります。このトークンは Google でアプリケーションを識別するためにも使用されます。

認証プロトコルについて

リクエストを承認するために、アプリケーションは OAuth 2.0 を使用する必要があります。これ以外の認証プロトコルには対応していません。アプリケーションで「Google でログイン」を使用している場合、承認手続きの一部が自動化されます。

OAuth 2.0 を使用したリクエストの承認

非公開のユーザーデータに対する Google サイト データ API へのリクエストは、認証済みユーザーによって承認される必要があります。

OAuth 2.0 の承認プロセス(「フロー」)の詳細は開発するアプリケーションの種類によって若干異なりますが、次の一般的なプロセスはすべての種類のアプリケーションに当てはまります。

  1. アプリケーションの作成時に、Google API Console を使用してアプリケーションを登録します。登録すると、後で必要になるクライアント ID やクライアント シークレットなどの情報が Google から提供されます。
  2. Google API Console で Google サイト データ API を有効にします。(Indexing API が API Console に表示されない場合は、この手順をスキップしてください)。
  3. アプリケーションでユーザーデータにアクセスする必要がある場合は、特定のアクセスのスコープを Google にリクエストします。
  4. データをリクエストするアプリケーションの承認を求める Google の同意画面がユーザーに表示されます。
  5. ユーザーが承認すると、有効期間の短いアクセス トークンがアプリケーションに付与されます。
  6. アプリケーションは、リクエストにそのアクセス トークンを付与してユーザーデータをリクエストします。
  7. Google がそのリクエストとトークンが有効であると判断すると、リクエストされたデータが返されます。

プロセスによっては、更新トークンを使用して新しいアクセス トークンを取得するなど、追加の手順が必要になる場合もあります。各種アプリケーションのフローについて詳しくは、Google の OAuth 2.0 ドキュメントをご覧ください。

Google サイト データ API で使用される OAuth 2.0 のスコープ情報は次のとおりです。

https://sites.google.com/feeds/

OAuth 2.0 を使用してアクセスをリクエストする場合、アプリケーションを登録したときに Google から提供された情報(クライアント ID やクライアント シークレットなど)に加えて、スコープ情報が必要になります。

トップへ戻る

バージョンの指定

Google サイト データ API に送信するすべてのリクエストで、バージョン 1.4 を指定する必要があります。バージョン番号を指定するには、GData-Version HTTP ヘッダーを使用します。

GData-Version: 1.4

または、HTTP ヘッダーを設定できない場合は、URL のクエリ パラメータとして v=1.4 を指定できます。ただし、可能であれば HTTP ヘッダーを使用することをおすすめします。

: クライアント ライブラリは適切なバージョン ヘッダーを自動的に提供するため、クライアント ライブラリを使用している場合は v=1.4 クエリ パラメータを使用しないでください。

トップへ戻る

サイトフィード

サイトフィードを使用すると、ユーザーが所有しているか、閲覧権限を持っている Google サイトを一覧表示したり、既存のサイトのタイトルを変更したりできます。G Suite ドメインの場合は、サイト全体の作成やコピーにも使用できます。

リスティング サイト

ユーザーがアクセスできるサイトの一覧を取得するには、次の URL に認証済みの GET リクエストを送信します。

https://sites.google.com/feeds/site/domainName
フィード パラメータ説明
domainNamesite」または G Suite でホストされているドメインのドメイン(例: example.com)。

レスポンスには、サイトのリストを含むフィードが含まれます。

GET /feeds/site/domainName HTTP/1.1
Host: sites.google.com
GData-Version: 1.4
Authorization: <your authorization header here>

HTTP/1.1 200 OK

<feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/"
    xmlns:gAcl="http://schemas.google.com/acl/2007" xmlns:sites="http://schemas.google.com/sites/2008"
    xmlns:gs="http://schemas.google.com/spreadsheets/2006" xmlns:dc="http://purl.org/dc/terms"
    xmlns:batch="http://schemas.google.com/gdata/batch" xmlns:gd="http://schemas.google.com/g/2005"
    xmlns:thr="http://purl.org/syndication/thread/1.0">
<id>https://sites.google.com/feeds/site/site</id>
<updated>2009-12-02T17:47:34.406Z</updated>
<title>Site</title>
<link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml"
    href="https://sites.google.com/feeds/site/site"/>
<link rel="http://schemas.google.com/g/2005#post" type="application/atom+xml"
    href="https://sites.google.com/feeds/feeds/site/domainName"/>
<link rel="self" type="application/atom+xml" href="https://sites.google.com/feeds/site/domainName"/>
<link rel="next" type="application/atom+xml" href="https://sites.google.com/feeds/site/domainName/?start-index=2"/>
<generator version="1" uri="http://sites.google.com/">Google Sites</generator>
<openSearch:startIndex>1</openSearch:startIndex>
<entry gd:etag="W/&quot;CkUAQH4_eil7I2A9WxNaFk4.&quot;">
  <id>https://sites.google.com/feeds/site/site/myTestSite</id>
  <updated>2009-12-01T01:17:21.042Z</updated>
  <app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-01T01:17:21.042Z</app:edited>
  <title>myTestSite</title>
  <summary/>
  <link rel="alternate" type="text/html" href="http://sites.google.com/site/myTestSite/"/>
  <link rel="http://schemas.google.com/acl/2007#accessControlList" type="application/atom+xml"
      href="https://sites.google.com/feeds/acl/site/domainName/myTestSite"/>
  <link rel="self" type="application/atom+xml" href="https://sites.google.com/feeds/site/domainName/myTestSite"/>
  <link rel="edit" type="application/atom+xml" href="https://sites.google.com/feeds/site/domainName/myTestSite"/>
  <sites:siteName>myTestSite</sites:siteName>
  <sites:theme>default</sites:theme>
</entry>
<entry gd:etag="W/&quot;DkQGQHczfA9WxNaFk4.&quot;">
  <id>https://sites.google.com/feeds/site/domainName/myOtherTestSite</id>
  <updated>2009-12-01T02:25:21.987Z</updated>
  <app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-01T02:25:21.987Z</app:edited>
  <title>myOtherTestSite</title>
  <summary>A new site to hold memories</summary>
  <category scheme="http://schemas.google.com/sites/2008#tag" term="Memories Site"/>
  <link rel="alternate" type="text/html" href="http://sites.google.com/site/myOtherTestSite"/>
  <link rel="http://schemas.google.com/acl/2007#accessControlList" type="application/atom+xml"
      href="https://sites.google.com/feeds/acl/site/domainName/myOtherTestSite"/>
  <link rel="self" type="application/atom+xml" href="https://sites.google.com/feeds/site/domainName/myOtherTestSite"/>
  <link rel="edit" type="application/atom+xml" href="https://sites.google.com/feeds/site/domainName/myOtherTestSite"/>
  <sites:siteName>myOtherTestSite</sites:siteName>
  <sites:theme>iceberg</sites:theme>
</entry>
...
</feed>

サイトはアルファベット順に表示されます。

新しいサイトの作成

: この機能は G Suite ドメインでのみご利用いただけます。

新しいサイトをプロビジョニングするには、サイトフィードに HTTP POST を実行します。例:

POST /feeds/site/example.com HTTP/1.1
Host: sites.google.com
GData-Version: 1.4
Authorization: <your authorization header here>

<entry xmlns="http://www.w3.org/2005/Atom" xmlns:sites="http://schemas.google.com/sites/2008">
  <title>Source Site</title>
  <summary>A new site to hold memories</summary>
  <sites:theme>slate</sites:theme>
</entry>

上記のリクエストにより、G Suite ドメイン example.com に「slate」テーマの新しい Google サイトが作成されます。サイトの URL は http://sites.google.com/a/example.com/source-site/ になります。

サイトが正常に作成されると、サーバーは 201 Created で応答します。レスポンス エントリには、サイトへのリンク、サイトの ACL フィードへのリンク、サイト名、タイトル、概要など、サーバーによって追加された要素が含まれます。

<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gAcl="http://schemas.google.com/acl/2007"
    xmlns:sites="http://schemas.google.com/sites/2008" xmlns:gs="http://schemas.google.com/spreadsheets/2006"
    xmlns:dc="http://purl.org/dc/terms" xmlns:batch="http://schemas.google.com/gdata/batch"
    xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0"
    gd:etag="W/&quot;DEECR38l7I2A9WxNaF0Q.&quot;">
  <id>https://sites.google.com/feeds/site/example.com/source-site</id>
  <updated>2009-12-02T23:31:06.184Z</updated>
  <app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-02T23:31:06.184Z</app:edited>
  <title>New Test Site</title>
  <summary>A new site to hold memories</summary>
  <link rel="alternate" type="text/html" href="http://sites.google.com/a/example.com/source-site/"/>
  <link rel="http://schemas.google.com/acl/2007#accessControlList" type="application/atom+xml"
      href="https://sites.google.com/feeds/acl/site/example.com/source-site"/>
  <link rel="self" type="application/atom+xml" href="https://sites.google.com/feeds/site/example.com/source-site"/>
  <link rel="edit" type="application/atom+xml" href="https://sites.google.com/feeds/site/example.com/source-site"/>
  <sites:siteName>source-site</sites:siteName>
  <sites:theme>slate</sites:theme>
</entry>

サイトをコピーする

: この機能は G Suite ドメインでのみご利用いただけます。

既存のサイトは、新しいサイトの作成と同じ方法で複製できます。ただし、POST リクエストの Atom エントリには、コピーするサイトのサイトフィードを指す rel='source' を含む <link> を含めます。コピーされたサイトにはこのリンクが含まれます。サイトを複製する例を次に示します。

POST /feeds/site/example.com HTTP/1.1
Host: sites.google.com
GData-Version: 1.4
Authorization: <your authorization header here>

<entry xmlns="http://www.w3.org/2005/Atom">
  <link rel="http://schemas.google.com/sites/2008#source" type="application/atom+xml"
      href="https://sites.google.com/feeds/site/example.com/source-site"/>
  <title>Copy of New Test Site</title>
  <summary>A newer site to hold memories</summary>
</entry>

上記のリクエストは、http://sites.google.com/a/example.com/source-site/ にあるサイトをコピーします。

注意事項:

  • コピーできるのは、認証されたユーザーが所有するサイトとサイト テンプレートのみです。
  • サイト テンプレートをコピーすることもできます。Google サイトの設定ページで [このサイトをテンプレートとして公開] 設定がオンになっている場合、そのサイトはテンプレートです。
  • 別のドメインからサイトをコピーするには、コピー元のサイトのオーナーとして登録されている必要があります。

サイトのメタデータを更新する

サイトのタイトルまたは概要を更新するには、サイトエントリの edit リンクに HTTP PUT を送信します。たとえば、次の例では、以前のサイトのタイトルを New Test Site2 に、説明を Newer description に更新します。

PUT /feeds/site/example.com/source-site HTTP/1.1
Host: sites.google.com
GData-Version: 1.4
Authorization: <your authorization header here>

<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gAcl="http://schemas.google.com/acl/2007"
    xmlns:sites="http://schemas.google.com/sites/2008" xmlns:gs="http://schemas.google.com/spreadsheets/2006"
    xmlns:dc="http://purl.org/dc/terms" xmlns:batch="http://schemas.google.com/gdata/batch"
    xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0"
    gd:etag="W/&quot;DEECR38l7I2A9WxNaF0Q.&quot;">
  <id>https://sites.google.com/feeds/site/example.com/source-site</id>
  <updated>2009-12-02T23:31:06.184Z</updated>
  <app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-02T23:31:06.184Z</app:edited>
  <title>New Test Site2</title>
  <summary>Newer description</summary>
  <category scheme="http://schemas.google.com/sites/2008#tag" term="Category"/>
  <link rel="alternate" type="text/html" href="http://sites.google.com/a/example.com/source-site/"/>
  <link rel="http://schemas.google.com/acl/2007#accessControlList" type="application/atom+xml"
      href="https://sites.google.com/feeds/acl/site/example.com/source-site"/>
  <link rel="self" type="application/atom+xml" href="https://sites.google.com/feeds/site/example.com/source-site"/>
  <link rel="edit" type="application/atom+xml" href="https://sites.google.com/feeds/site/example.com/source-site"/>
  <sites:siteName>source-site</sites:siteName>
</entry>

カテゴリを追加する

: この機能は G Suite ドメインでのみご利用いただけます。

G Suite for your Domain サイトには、ドメイン内のサイトを分類するのに役立つカテゴリ メタデータが含まれています。カテゴリのメタデータを追加または更新するには、category タグを含む HTTP PUT をサイト エントリの edit リンクに送信します。次の例の太字の行をご覧ください。

PUT /feeds/site/example.com/source-site HTTP/1.1
Host: sites.google.com
GData-Version: 1.4
Authorization: <your authorization header here>

<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gAcl="http://schemas.google.com/acl/2007"
    xmlns:sites="http://schemas.google.com/sites/2008" xmlns:gs="http://schemas.google.com/spreadsheets/2006"
    xmlns:dc="http://purl.org/dc/terms" xmlns:batch="http://schemas.google.com/gdata/batch"
    xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0"
    gd:etag="W/&quot;DEECR38l7I2A9WxNaF0Q.&quot;">
  <id>https://sites.google.com/feeds/site/example.com/source-site</id>
  <updated>2009-12-02T23:31:06.184Z</updated>
  <app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-02T23:31:06.184Z</app:edited>
  <title>My Team website</title>
  <summary>This site contains contact information and a summary of major efforts our team owns</summary>
  <category scheme="http://schemas.google.com/sites/2008#tag" term="Team Site"/>
  <link rel="alternate" type="text/html" href="http://sites.google.com/a/example.com/my-team-site/"/>
  <link rel="http://schemas.google.com/acl/2007#accessControlList" type="application/atom+xml"
      href="https://sites.google.com/feeds/acl/site/example.com/my-team-site"/>
  <link rel="self" type="application/atom+xml" href="https://sites.google.com/feeds/site/example.com/my-team-site"/>
  <link rel="edit" type="application/atom+xml" href="https://sites.google.com/feeds/site/example.com/my-team-site"/>
  <sites:siteName>my-team-site</sites:siteName>
</entry>

この例では、既存のサイトを編集して「チームサイト」カテゴリを追加します。

<category> タグを追加することで、複数のカテゴリを追加することもできます。次の例の太字の行をご覧ください。

PUT /feeds/site/example.com/my-team-site HTTP/1.1
Host: sites.google.com
GData-Version: 1.4
Authorization: <your authorization header here>

<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gAcl="http://schemas.google.com/acl/2007"
    xmlns:sites="http://schemas.google.com/sites/2008" xmlns:gs="http://schemas.google.com/spreadsheets/2006"
    xmlns:dc="http://purl.org/dc/terms" xmlns:batch="http://schemas.google.com/gdata/batch"
    xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0"
    gd:etag="W/&quot;DEECR38l7I2A9WxNaF0Q.&quot;">
  <id>https://sites.google.com/feeds/site/example.com/my-team-site</id>
  <updated>2009-12-02T23:31:06.184Z</updated>
  <app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-02T23:31:06.184Z</app:edited>
  <title>My Team website</title>
  <summary>This site contains contact information and a summary of major efforts our team owns</summary>
  <category scheme="http://schemas.google.com/sites/2008#tag" term="Team Site/">
  <category scheme="http://schemas.google.com/sites/2008#tag" term="Legal Department/">
  <link rel="alternate" type="text/html" href="http://sites.google.com/a/example.com/my-team-site/"/>
  <link rel="http://schemas.google.com/acl/2007#accessControlList" type="application/atom+xml"
      href="https://sites.google.com/feeds/acl/site/example.com/my-team-site"/>
  <link rel="self" type="application/atom+xml" href="https://sites.google.com/feeds/site/example.com/my-team-site"/>
  <link rel="edit" type="application/atom+xml" href="https://sites.google.com/feeds/site/example.com/my-team-site"/>
  <sites:siteName>my-team-site</sites:siteName>
</entry>

この例では、「チーム サイト」と「法務部門」の 2 つのカテゴリを追加します。

ウェブアドレスのマッピング

ウェブアドレスのマッピングを使用すると、Google サイトのユーザーは自分のドメインを Google サイトにマッピングできます。たとえば、http://sites.google.com/a/domain.com/mysite の代わりに http://www.mydomainsite.com を使用できます。サイトのホスティング場所によっては、サイトのウェブアドレスのマッピングを手動で変更できます。詳しくは、ヘルプセンターの記事をご覧ください。

サイトのウェブアドレスのマッピングを取得する

サイトのウェブアドレス マッピングを返すには、with-mappings=true パラメータを使用してサイトのエントリ/フィードを取得します。

GET /feeds/site/domainName?with-mappings=true HTTP/1.1
Host: sites.google.com
GData-Version: 1.4
Authorization: <your authorization header here>

HTTP/1.1 200 OK

<feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/"
    xmlns:gAcl="http://schemas.google.com/acl/2007" xmlns:sites="http://schemas.google.com/sites/2008"
    xmlns:gs="http://schemas.google.com/spreadsheets/2006" xmlns:dc="http://purl.org/dc/terms"
    xmlns:batch="http://schemas.google.com/gdata/batch" xmlns:gd="http://schemas.google.com/g/2005"
    xmlns:thr="http://purl.org/syndication/thread/1.0">
...
<entry gd:etag="W/&quot;DkQGQHczfA9WxNaFk4.&quot;">
  <id>https://sites.google.com/feeds/site/domainName/myOtherTestSite</id>
  <updated>2009-12-01T02:25:21.987Z</updated>
  <app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-01T02:25:21.987Z</app:edited>
  <title>myOtherTestSite</title>
  <summary>A new site to hold memories</summary>
  <link rel="alternate" type="text/html" href="http://sites.google.com/site/myOtherTestSite"/>
  <link rel="http://schemas.google.com/acl/2007#accessControlList" type="application/atom+xml"
      href="https://sites.google.com/feeds/acl/site/domainName/myOtherTestSite"/>
  <link rel="self" type="application/atom+xml" href="https://sites.google.com/feeds/site/domainName/myOtherTestSite"/>
  <link rel="edit" type="application/atom+xml" href="https://sites.google.com/feeds/site/domainName/myOtherTestSite"/>
  <link rel='webAddressMapping' href='http://www.mysitemapping.com'>
  <link rel='webAddressMapping' href='http://www.mysitemapping2.com'>
  <link rel='webAddressMapping' href='http://www.myothermapping.org'>
</entry>
...
</feed>

既存のマッピングは、rel='webAddressMapping' の link として表示されます。たとえば、上記の例では、サイト http://sites.google.com/site/myOtherTestSite を指す webAddressMapping が 3 つあります。

ウェブアドレスのマッピングを変更する

: ウェブアドレス マッピングを使用する場合は、すべての GET/POST/PUT オペレーションで with-mappings=true パラメータを指定する必要があります。パラメータがない場合、サイト エントリ(GET)で webAddressMapping は返されず、エントリからマッピングを更新/削除(PUT)する際に考慮されません。

マッピングを追加、更新、削除するには、新しいサイトを作成するか、サイトのメタデータを更新する際に、そのようなリンクを指定、変更、削除します。with-mappings=true パラメータはサイトフィード URI に含める必要があります。注: アドレス マッピングを更新するには、サイト管理者である必要があります。G Suite でホストされているサイトの場合は、ドメイン管理者である必要があります。

たとえば、次のリクエストは http://www.mysitemapping.com マッピングを http://www.my-new-sitemapping.com に更新し、エントリからリンクを除外することで http://www.mysitemapping2.com を削除します。

PUT /feeds/site/domainName?with-mappings=true HTTP/1.1
Host: sites.google.com
GData-Version: 1.4
Authorization: <your authorization header here>

<entry gd:etag="W/&quot;DkQGQHczfA9WxNaFk4.&quot;">
  <id>https://sites.google.com/feeds/site/domainName/myOtherTestSite</id>
  <updated>2009-12-01T02:25:21.987Z</updated>
  <app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-01T02:25:21.987Z</app:edited>
  <title>myOtherTestSite</title>
  <summary>A new site to hold memories</summary>
  <link rel="alternate" type="text/html" href="http://sites.google.com/site/myOtherTestSite"/>
  <link rel="http://schemas.google.com/acl/2007#accessControlList" type="application/atom+xml"
      href="https://sites.google.com/feeds/acl/site/domainName/myOtherTestSite"/>
  <link rel="self" type="application/atom+xml" href="https://sites.google.com/feeds/site/domainName/myOtherTestSite"/>
  <link rel="edit" type="application/atom+xml" href="https://sites.google.com/feeds/site/domainName/myOtherTestSite"/>
  <link rel='webAddressMapping' href='www.my-new-sitemapping.com'>
  <!-- missing mapping2 will be deleted -->
  <link rel='webAddressMapping' href='http://www.myothermapping.org'>
</entry>

なお、ウェブアドレスのマッピングは、サイトの作成時やコピー時にも指定できます。

トップへ戻る

アクティビティ フィード

アクティビティ フィードを取得することで、サイトの最近のアクティビティ(変更)を取得できます。アクティビティ フィードの各エントリには、サイトに加えられた変更に関する情報が含まれています。

アクティビティ フィードをクエリするには、アクティビティ フィードの URL に HTTP GET を送信します。

https://sites.google.com/feeds/activity/domainName/siteName
フィード パラメータ説明
domainNamesite」または G Suite でホストされているドメインのドメイン(例: example.com)。
siteNameサイトのウェブスペース名。サイトの URL(例: myCoolSite)で確認できます。

リクエストとレスポンスの例

GET /feeds/activity/site/siteName HTTP/1.1
Host: sites.google.com
GData-Version: 1.4
Authorization: <your authorization header here>

HTTP/1.1 200 OK

<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/">
<id>https://sites.google.com/feeds/activity/site/siteName</id>
<updated>2009-09-10T05:24:23.120Z</updated>
<title>Activity</title>
<link rel="alternate" type="text/html" href="http://sites.google.com/site/siteName/system/app/pages/recentChanges"/>
<link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml"
  href="https://sites.google.com/feeds/activity/site/siteName"/>
<link rel="self" type="application/atom+xml"
  href="https://sites.google.com/feeds/activity/site/siteName"/>
<generator version="1" uri="http://sites.google.com">Google Sites</generator>
<openSearch:startIndex>1</openSearch:startIndex>
<entry xmlns:gd="http://schemas.google.com/g/2005" gd:etag="W/&quot;CU4GQ3szfSl7ImA9WxNRFUg.&quot;">
<id>https://sites.google.com/feeds/activity/site/siteName/940375996952876062</id>
<updated>2009-09-10T03:38:42.585Z</updated>
<category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#deletion" label="deletion"/>
<title>home</title>
<summary type="xhtml">
  <div xmlns="http://www.w3.org/1999/xhtml">User deleted <a href="http://sites.google.com/site/siteName/home">home</a>
</div>
</summary>
<link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml"
  href="https://sites.google.com/feeds/revision/site/siteName/5409745539831916487"/>
<link rel="http://schemas.google.com/sites/2008#current" type="application/atom+xml"
  href="https://sites.google.com/feeds/content/site/siteName/5409745539831916487"/>
<link rel="self" type="application/atom+xml"
  href="https://sites.google.com/feeds/activity/site/siteName/940375996952876062"/>
<author>
  <name>User</name>
  <email>user@gmail.com</email>
</author>
</entry>
<entry xmlns:gd="http://schemas.google.com/g/2005" gd:etag="W/&quot;CU8DQn45fyl7ImA9WxNRFUg.&quot;">
  <id>https://sites.google.com/feeds/activity/site/siteName/7165439066235480082</id>
  <updated>2009-09-10T03:37:53.027Z</updated>
  <category scheme="http://schemas.google.com/g/2005#kind"
    term="http://schemas.google.com/sites/2008#edit" label="edit"/>
  <title>home</title>
  <summary type="xhtml">
    <div xmlns="http://www.w3.org/1999/xhtml">User2 edited <a href="http://sites.google.com/site/siteName/home">home</a>
  </div>
  </summary>
  <link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml"
    href="https://sites.google.com/feeds/revision/site/siteName/5409745539831916487"/>
  <link rel="http://schemas.google.com/sites/2008#current" type="application/atom+xml"
    href="https://sites.google.com/feeds/content/site/siteName/5409745539831916487"/>
  <link rel="self" type="application/atom+xml"
    href="https://sites.google.com/feeds/activity/site/siteName/7165439066235480082"/>
  <author>
    <name>User</name>
    <email>user@gmail.com</email>
  </author>
</entry>
<entry xmlns:gd="http://schemas.google.com/g/2005" gd:etag="W/&quot;CU8AR3s4cSl7ImA9WxNRFUg.&quot;">
  <id>https://sites.google.com/feeds/activity/site/siteName/127448462987345884</id>
  <updated>2009-09-10T03:37:26.539Z</updated>
  <category scheme="http://schemas.google.com/g/2005#kind"
    term="http://schemas.google.com/sites/2008#creation" label="creation"/>
  <title>home</title>
  <summary type="xhtml">
    <div xmlns="http://www.w3.org/1999/xhtml">User3 created <a href="http://sites.google.com/site/siteName/home">home</a>
  </div>
  </summary>
  <link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml"
    href="https://sites.google.com/feeds/revision/site/siteName/5409745539831916487"/>
  <link rel="http://schemas.google.com/sites/2008#current" type="application/atom+xml"
    href="https://sites.google.com/feeds/content/site/siteName/5409745539831916487"/>
  <link rel="self" type="application/atom+xml"
    href="https://sites.google.com/feeds/activity/site/siteName/127448462987345884"/>
  <author>
    <name>User3</name>
    <email>user3@gmail.com</email>
  </author>
</entry>
</feed>

: このフィードにアクセスするには、サイトの共同編集者または所有者である必要があります。クライアントは、正しい Authorization ヘッダーを送信し、リクエストの承認で取得したトークンを参照する必要があります。

トップへ戻る

リビジョン フィード

コンテンツ エントリの変更履歴を取得するには、エントリの変更リンクに HTTP GET を送信します。

https://sites.google.com/feeds/revision/domainName/siteName/CONTENT_ENTRY_ID
フィード パラメータ説明
domainNamesite」または G Suite でホストされているドメインのドメイン(例: example.com)。
siteNameサイトのウェブスペース名。サイトの URL(例: myCoolSite)で確認できます。

特定のページ、コメント、添付ファイル、リストアイテムのリビジョン リンクを見つけるには、まず CONTENT_ENTRY_ID を使用してコンテンツ フィードからエントリを取得します。取得されたエントリには、リビジョン フィードへの <atom:link> が含まれます。次に例を示します。

<link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml"
    href="https://sites.google.com/feeds/revision/domainName/siteName/CONTENT_ENTRY_ID"/>

リクエストとレスポンスの例

GET /feeds/revision/domainName/siteName/CONTENT_ENTRY_ID HTTP/1.1
Host: sites.google.com
GData-Version: 1.4
Authorization: <your authorization header here>

HTTP/1.1 200 OK

<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/"
    xmlns:sites="http://schemas.google.com/sites/2008" xmlns:gs="http://schemas.google.com/spreadsheets/2006"
    xmlns:dc="http://purl.org/dc/terms" xmlns:batch="http://schemas.google.com/gdata/batch"
    xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0">
<id>https://sites.google.com/feeds/revision/domainName/siteName/CONTENT_ENTRY_ID</id>
<updated>2009-09-10T04:33:35.337Z</updated>
<title>Revisions</title>
<link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml"
    href="https://sites.google.com/feeds/revision/domainName/siteName/CONTENT_ENTRY_ID"/>
<link rel="self" type="application/atom+xml"
    href="https://sites.google.com/feeds/revision/domainName/siteName/CONTENT_ENTRY_ID"/>
<generator version="1" uri="http://sites.google.com">Google Sites</generator>
<openSearch:startIndex>1</openSearch:startIndex>
<entry gd:etag="W/&quot;CU4GQmA9WxNRFUg.&quot;">
  <id>https://sites.google.com/feeds/revision/domainName/siteName/CONTENT_ENTRY_ID/2</id>
  <updated>2009-09-10T03:38:42.045Z</updated>
  <category scheme="http://schemas.google.com/g/2005#kind"
      term="http://schemas.google.com/sites/2008#webpage" label="webpage"/>
  <title>Home</title>
  <content type="xhtml">
    <div xmlns="http://www.w3.org/1999/xhtml">Latest content here</div>
  </content>
  <link rel="alternate" type="text/html"
    href="http://sites.google.com/domainName/siteName/CONTENT_ENTRY_ID/system/app/pages/admin/compare?wuid=wuid%3Agx%3A4f67c7&amp;rev1=2"/>
  <link rel="self" type="application/atom+xml" href="https://sites.google.com/feeds/revision/domainName/siteName/CONTENT_ENTRY_ID/2"/>
  <author>
    <name>User</name>
    <email>user@gmail.com</email>
  </author>
  <sites:pageName>home</sites:pageName>
  <sites:revision>2</sites:revision>
</entry>
<entry gd:etag="W/&quot;CU8DQ388eSl7ImA9WxNRFUg.&quot;">
  <id>https://sites.google.com/feeds/revision/domainName/siteName/CONTENT_ENTRY_ID/1</id>
  <updated>2009-09-10T03:37:52.171Z</updated>
  <category scheme="http://schemas.google.com/g/2005#kind"
      term="http://schemas.google.com/sites/2008#webpage" label="webpage"/>
  <title>Home</title>
  <content type="xhtml">
    <div xmlns="http://www.w3.org/1999/xhtml">Older content here</div>
  </content>
  <link rel="alternate" type="text/html"
    href="http://sites.google.com/domainName/siteName/CONTENT_ENTRY_ID/system/app/pages/admin/compare?wuid=wuid%3Agx%3A4bc7&amp;rev1=1"/>
  <link rel="self" type="application/atom+xml"
    href="https://sites.google.com/feeds/revision/domainName/siteName/CONTENT_ENTRY_ID/1"/>
  <author>
    <name>User</name>
    <email>user@gmail.com</email>
  </author>
  <sites:pageName>home</sites:pageName>
  <sites:revision>1</sites:revision>
</entry>
</feed>

: このフィードにアクセスするには、サイトの共同編集者または所有者である必要があります。クライアントは、正しい Authorization ヘッダーを送信し、リクエストの承認で取得したトークンを参照する必要があります。

トップへ戻る

コンテンツ フィード

コンテンツの取得

コンテンツ フィードには、サイトの現在のコンテンツが一覧表示されます。次の URL に認証済みの GET リクエストを送信します。

https://sites.google.com/feeds/content/domainName/siteName
フィード パラメータ説明
domainNamesite」または G Suite でホストされているドメインのドメイン(例: example.com)。
siteNameサイトのウェブスペース名。サイトの URL(例: myCoolSite)で確認できます。

結果として、サイトのコンテンツ エントリの最初のページを一覧表示するフィードが生成されます。フィード内の各エントリは、webpagefilecabinetattachmentcomment などのさまざまなタイプのコンテンツ エントリを表します。<category scheme="http://schemas.google.com/g/2005#kind"> 要素はエントリのタイプを決定します。サポートされている kind 値の一覧については、リファレンス ガイドをご覧ください。

: このフィードでは、サイトの共有権限に応じて認証が必要になる場合があります。サイトが非公開の場合は、クライアントは正しい Authorization ヘッダー(上記の例を参照)を送信し、リクエストの承認で取得したトークンを参照する必要があります。

GET /feeds/content/domainName/siteName HTTP/1.1
Host: sites.google.com
GData-Version: 1.4
Authorization: <your authorization header here>

HTTP/1.1 200 OK

<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/"
  xmlns:sites="http://schemas.google.com/sites/2008" xmlns:gs="http://schemas.google.com/spreadsheets/2006"
  xmlns:dc="http://purl.org/dc/terms" xmlns:batch="http://schemas.google.com/gdata/batch"
  xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0">
<id>https://sites.google.com/feeds/content/domainName/siteName</id>
<updated>2009-08-31T01:39:20.286Z</updated>
<title>Content</title>
<link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml"
    href="https://sites.google.com/feeds/content/domainName/siteName"/>
<link rel="http://schemas.google.com/g/2005#post" type="application/atom+xml"
    href="https://sites.google.com/feeds/content/domainName/siteName"/>
<link rel="self" type="application/atom+xml"
    href="https://sites.google.com/feeds/content/domainName/siteName"/>
<link rel="http://schemas.google.com/g/2005#batch" type="application/atom+xml"
    href="https://sites.google.com/feeds/content/domainName/siteName/batch""/>
<link rel="next" type="application/atom+xml" href="https://sites.google.com/feeds/content/domainName/siteName/?start-index=2"/>
<generator version="1" uri="http://sites.google.com">Google Sites</generator>
<openSearch:startIndex>1</openSearch:startIndex>
<entry gd:etag="W/&quot;Ck8GQXk7fil7ImA9WxNSFk0.&quot;">
  <id>https://sites.google.com/feeds/content/domainName/siteName/7322156894</id>
  <updated>2009-08-30T02:53:40.706Z</updated>
  <app:edited xmlns:app="http://www.w3.org/2007/app">2009-08-30T02:53:40.706Z</app:edited>
  <category scheme="http://schemas.google.com/g/2005#kind"
      term="http://schemas.google.com/sites/2008#webpage" label="webpage"/>
  <title>Subpage</title>
  <content type="xhtml">
    <div xmlns="http://www.w3.org/1999/xhtml">Page html content here</div>
  </content>
  <link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml"
      href="https://sites.google.com/feeds/content/domainName/siteName/6492205817"/>
  <link rel="alternate" type="text"
      href="http://sites.google.com/site/siteName/subpage"/>
  <link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml"
      href="https://sites.google.com/feeds/revision/domainName/siteName/7322156894"/>
  <link rel="self" type="application/atom+xml"
      href="https://sites.google.com/feeds/content/domainName/siteName/7322156894"/>
  <link rel="edit" type="application/atom+xml"
      href="https://sites.google.com/feeds/content/domainName/siteName/7322156894"/>
  <author>
    <name>User</name>
    <email>user@gmail.com</email>
  </author>
  <sites:pageName>subpage</sites:pageName>
  <sites:revision>5</sites:revision>
</entry>
<entry gd:etag="W/&quot;CkMBQH08fCl7ImA9WxNSFk0.&quot;">
  <id>https://sites.google.com/feeds/content/domainName/siteName/5930635231</id>
  <updated>2009-08-30T02:47:31.374Z</updated>
  <app:edited xmlns:app="http://www.w3.org/2007/app">2009-08-30T02:47:31.374Z</app:edited>
  <category scheme="http://schemas.google.com/g/2005#kind"
      term="http://schemas.google.com/sites/2008#listitem" label="listpage"/>
  <title/>
  <link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml"
      href="https://sites.google.com/feeds/content/domainName/siteName/5930635231"/>
  <link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml"
      href="https://sites.google.com/feeds/revision/domainName/siteName/5930635231"/>
  <link rel="self" type="application/atom+xml"
      href="https://sites.google.com/feeds/content/domainName/siteName/5930635231"/>
  <link rel="edit" type="application/atom+xml"
      href="https://sites.google.com/feeds/content/domainName/siteName/5930635231"/>
  <author>
    <name>User</name>
    <email>user@gmail.com</email>
  </author>
  <sites:revision>1</sites:revision>
  <gs:field index="A" name="Issue/Feature">Implement cool feature X</gs:field>
  <gs:field index="B" name="Priority">P2</gs:field>
  <gs:field index="C" name="Owner"/>
  <gs:field index="D" name="Resolved"/>
</entry>
<entry gd:etag="W/&quot;AkYHQ3ozcCl7ImA9WxJaE08.&quot;">
  <id>https://sites.google.com/feeds/content/domainName/siteName/1265948545471894517</id>
  <updated>2009-08-03T19:35:32.488Z</updated>
  <app:edited xmlns:app="http://www.w3.org/2007/app">2009-08-03T19:35:32.488Z</app:edited>
  <category scheme="http://schemas.google.com/g/2005#kind"
      term="http://schemas.google.com/sites/2008#filecabinet" label="filecabinet"/>
  <title>files</title>
  <content type="xhtml">
    <div xmlns="http://www.w3.org/1999/xhtml">Page html content here</div>
  </content>
  <link rel="alternate" type="text"
      href="https://sites.google.com/domainName/siteName/files"/>
  <link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml"
      href="https://sites.google.com/feeds/revision/domainName/siteName/12671894517"/>
  <link rel="self" type="application/atom+xml"
      href="https://sites.google.com/feeds/content/domainName/siteName/12671894517"/>
  <link rel="edit" type="application/atom+xml"
      href="https://sites.google.com/feeds/content/domainName/siteName/12671894517"/>
  <author>
    <name>User</name>
    <email>user@gmail.com</email>
  </author>
  <gd:feedLink href="httpn://sites.google.com/feeds/content/domainName/siteName?parent=12671894517"/>
  <sites:pageName>files</sites:pageName>
  <sites:revision>1</sites:revision>
</entry>
...
</feed>

: これは最初の数件の結果にすぎません。コンテンツ フィード全体をページングするには、フィードの「次へ」リンクをたどります。

<link rel="next" type="application/atom+xml" href="https://sites.google.com/feeds/content/domainName/siteName/?start-index=2"/>

Atom の共通要素の説明については、Google Data Protocol リファレンスをご覧ください。以下に、クラシック サイト API で特定の意味を持つ要素について説明します。種類のエントリによっては、追加のプロパティ(下記に記載されていないもの)が含まれる場合があります。たとえば、listitem エントリには <gs:field> 要素が含まれることがありますが、webpage エントリには含まれません。

要素説明
<content ...>内部テキストはページの HTML 本文です。一部のエントリ(添付ファイルなど)の場合、この要素にはファイルを参照する src 属性が含まれます。
<link rel="alternate" ...>Google サイトのページまたはアイテムへのリンク。
<link rel="http://schemas.google.com/sites/2008#revision" ...>href 属性はエントリのリビジョン フィードを指します。
<link rel="http://schemas.google.com/sites/2008#parent" ...>href 属性はエントリの親エントリを指します。
<link rel="http://schemas.google.com/sites/2008#template" ...>href 属性はエントリのテンプレート ページを指します。
<category scheme="http://schemas.google.com/g/2005#kind" ...>label はエントリのタイプです。
<category term="http://schemas.google.com/g/2005#template" ...>label=template。エントリがテンプレートであることを示します。
<gd:feedLink>href 属性は、エントリの親の子を指します。
<sites:pageName>ページのウェブスペース名。ページの URL の名前に対応します。
<sites:revision>現在のリビジョン番号。

コンテンツ フィードのクエリの例

コンテンツ フィードは、標準の Google Data API クエリ パラメータと、クラシック Sites API 固有のパラメータを使用して検索できます。詳細とサポートされているパラメータの一覧については、リファレンス ガイドをご覧ください。

特定のエントリ種類の取得

特定のエントリタイプのみを取得するには、kind パラメータを使用します。この例では、webpage エントリのみが返されます。

GET /feeds/content/domainName/siteName?kind=webpage

複数のエントリ タイプを返すには、各 kind を「,」で区切ります。次の例では、filecabinet エントリと listpage エントリを返します。

GET /feeds/content/domainName/siteName?kind=filecabinet,listpage

または、kind パラメータの代わりに、Google Data /-/category クエリの標準形式を使用することもできます。

GET /feeds/content/domainName/siteName/-/filecabinet|listpage

ページ テンプレートの取得

この例では、template ページのみが返されます。

GET /feeds/content/domainName/siteName/-/template

すべてのエントリタイプを返し、template ページを含めるには、次のようにします。

GET /feeds/content/domainName/siteName/-/template|-template

パスでページを取得する

Google サイト内のページの相対パスがわかっている場合は、path パラメータを使用してその特定のページを取得できます。この例では、http://sites.google.com/site/siteName/path/to/the/page にあるページが返されます。

GET /feeds/content/domainName/siteName?path=/path/to/the/page

親ページの下にあるすべてのエントリを取得する

ページの ID がわかっている場合は、parent パラメータを使用して、すべての子エントリ(存在する場合)を取得できます。

GET /feeds/content/domainName/siteName?parent=CONTENT_ENTRY_ID

下書きや削除されたエントリを含む

下書きまたは削除されたエントリを含めるには、それぞれ include-drafts パラメータまたは include-deleted パラメータを使用します。この例では、コンテンツ フィードに下書きエントリが含まれています。

GET /feeds/content/domainName/siteName?include-drafts=true

全文検索

サイトのコンテンツ全体を検索するには、q パラメータを使用して全文検索を発行します。

GET /feeds/content/domainName/siteName?q=Text%20I%20am%20looking%20for

トップへ戻る



コンテンツの作成

新しいコンテンツ(ウェブページ、リストページ、ファイルキャビネット ページ、お知らせページなど)は、コンテンツ フィードに HTTP POST を送信することで作成できます。

https://sites.google.com/feeds/content/domainName/siteName

サポートされているエントリ タイプの一覧については、リファレンス ガイドkind パラメータをご覧ください。

新しいアイテム / ページの作成

この例では、サイトの最上位に新しい webpage を作成し、ページ本文の XHTML を含め、見出しのタイトルを「New WebPage Title」に設定します。

POST /feeds/content/domainName/siteName HTTP/1.1
Host: sites.google.com
GData-Version: 1.4
Authorization: <your authorization header here>
Content-Length: 328
Content-Type: application/atom+xml

<entry xmlns="http://www.w3.org/2005/Atom">
  <category scheme="http://schemas.google.com/g/2005#kind"
      term="http://schemas.google.com/sites/2008#webpage" label="webpage"/>
  <title>New Webpage Title</title>
  <content type="xhtml">
    <div xmlns="http://www.w3.org/1999/xhtml">HTML body goes here</div>
  </content>
</entry>

成功すると、サーバーは 201 Created とエントリのコピーを返します。

カスタム URL パスでアイテムやページを作成する

デフォルトでは、上記の例は URL http://sites.google.com/domainName/siteName/new-webpage-title の下に作成され、ページの見出しは「New Webpage Title」になります。つまり、URL の <atom:title>new-webpage-title に正規化されます。ページの URL パスをカスタマイズするには、<sites:pageName> 要素を設定します。

この例では、ページ見出しが「ファイル ストレージ」の新しい filecabinet を作成しますが、<sites:pageName> 要素を指定することで、URL http://sites.google.com/domainName/siteName/files の下にページを作成します。

POST /feeds/content/domainName/siteName HTTP/1.1
Host: sites.google.com
GData-Version: 1.4
Authorization: <your authorization header here>
Content-Length: 393
Content-Type: application/atom+xml

<entry xmlns="http://www.w3.org/2005/Atom" xmlns:sites="http://schemas.google.com/sites/2008">
  <category scheme="http://schemas.google.com/g/2005#kind"
      term="http://schemas.google.com/sites/2008#filecabinet" label="filecabinet"/>
  <title>File Storage</title>
  <content type="xhtml">
    <div xmlns="http://www.w3.org/1999/xhtml">A list of files is below.</div>
  </content>
  <sites:pageName>files</sites:pageName>
</entry>

サーバーは、ページの URL パスの命名に次の優先順位ルールを使用します。

  1. <sites:pageName>(存在する場合)。a-z, A-Z, 0-9, -, _ を満たす必要があります。
  2. <atom:title>。pageName が存在しない場合は null にすることはできません。正規化とは、空白文字をトリミングして '-' に折りたたみ、a-z, A-Z, 0-9, -, _ に一致しない文字を削除することです。

たとえば、'Custom_Page2' はサーバーで受け付けられます。

サブページの作成

親ページの下にサブページ(子)を作成するには、新しい Atom エントリに <link rel="http://schemas.google.com/sites/2008#parent"> を含めます。リンクの href 属性を親エントリのセルフリンクに設定します。

この例では、エントリ ID PARENT_ENTRY_ID の親お知らせページの下に、見出し「announcement」の新しい announcement を作成します。ページ本文の XHTML コンテンツも含まれています。

POST /feeds/content/domainName/siteName HTTP/1.1
Host: sites.google.com
GData-Version: 1.4
Authorization: <your authorization header here>
Content-Length: 470
Content-Type: application/atom+xml

<entry xmlns="http://www.w3.org/2005/Atom">
  <category scheme="http://schemas.google.com/g/2005#kind"
      term="http://schemas.google.com/sites/2008#announcement" label="announcement"/>
  <link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml"
      href="https://sites.google.com/feeds/content/domainName/siteName/PARENT_ENTRY_ID"/>
  <title>announcement</title>
  <content type="xhtml">
    <div xmlns="http://www.w3.org/1999/xhtml">This weekend. My place.</div>
  </content>
</entry>

ページ テンプレート

ページ テンプレートの作成

ページ テンプレートの作成プロセスは、新しいアイテム/ページの作成サブページの作成と同じです。異なるのは、それぞれ 'http://schemas.google.com/g/2005#template' と 'template' に設定された term と label を持つ category が追加されることです。

この例では、新しい webpage テンプレートを作成します。

POST /feeds/content/domainName/siteName HTTP/1.1
Host: sites.google.com
GData-Version: 1.4
Authorization: <your authorization header here>
Content-Length: 464
Content-Type: application/atom+xml

<entry xmlns="http://www.w3.org/2005/Atom" xmlns:sites="http://schemas.google.com/sites/2008">
  <category scheme="http://schemas.google.com/g/2005#kind"
      term="http://schemas.google.com/sites/2008#webpage" label="webpage"/>
  <category scheme="http://schemas.google.com/g/2005#labels" term="http://schemas.google.com/g/2005#template" label="template"/>
  <title>Webpage Template</title>
  <content type="xhtml">
    <div xmlns="http://www.w3.org/1999/xhtml">This weekend. My place.</div>
  </content>
</entry>

テンプレートからページを作成する

ページ テンプレートの作成と同様に、ページ テンプレートのセルフリンクを指す rel='http://schemas.google.com/sites/2008#template' を含む <link> を含めることで、テンプレートから新しいページをインスタンス化できます。

この例では、ファイルキャビネットを定義する既存のページ テンプレートから新しい filecabinet ページを作成します。

POST /feeds/content/domainName/siteName HTTP/1.1
Host: sites.google.com
GData-Version: 1.4
Authorization: <your authorization header here>
Content-Length: 464
Content-Type: application/atom+xml

<entry xmlns="http://www.w3.org/2005/Atom" xmlns:sites="http://schemas.google.com/sites/2008">
  <category scheme="http://schemas.google.com/g/2005#kind"
      term="http://schemas.google.com/sites/2008#filecabinet" label="filecabinet"/>
  <title>File Cabinet Page From Template</title>
  <link rel='http://schemas.google.com/sites/2008#template' type='application/atom+xml'
    href='https://sites.google.com/feeds/content/domainName/siteName/ENTRY_ID'/>
</entry>

: テンプレートで <category> が定義されていても、エントリに 1 つ含める必要があります。また、<content> 要素を含めると、サーバーによって拒否されます。

ファイルのアップロード

Google サイトと同様に、API を使用してファイル キャビネット ページと親ページに添付ファイルをアップロードできます。

添付ファイルを親にアップロードするには、HTTP POST リクエストをコンテンツ フィードの URL に送信します。

https://sites.google.com/feeds/content/domainName/siteName

POST 本文は、添付ファイルのメタデータを含む <atom:entry> とファイルの内容を組み合わせる MIME マルチパート リクエストにする必要があります。<atom:entry> は、添付ファイルが作成される場所を指定するために、親エントリのセルフリンクを参照する必要があります。詳しくは、サブページを作成するをご覧ください。

添付ファイルをアップロード中

次に、ID が PARENT_ENTRY_ID のファイル キャビネットに PDF ファイルをアップロードする例を示します。添付ファイルは、タイトル「PDF ファイル」と説明「HR パケット」(省略可)で作成されます。

POST /feeds/content/domainName/siteName HTTP/1.1
Host: sites.google.com
GData-Version: 1.4
Authorization: <your authorization header here>
Content-Length: 7221984
Content-Type: multipart/related; boundary=END_OF_PART
--END_OF_PART
Content-Type: application/atom+xml

<entry xmlns="http://www.w3.org/2005/Atom">
  <category scheme="http://schemas.google.com/g/2005#kind"
          term="http://schemas.google.com/sites/2008#attachment" label="attachment"/>
  <link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml"
        href="https://sites.google.com/feeds/content/domainName/siteName/PARENT_ENTRY_ID"/>
  <title>PDF File</title>
  <summary>HR packet</summary>
</entry>

--END_OF_PART
Content-Type: application/pdf

... pdf contents here ...

--END_OF_PART--

アップロードが成功すると、サーバーは 201 Created と、新しく作成された添付ファイル エントリのコピーを返します。

フォルダへの添付ファイルのアップロード

filecabinet の既存のフォルダに添付ファイルをアップロードするには、フォルダ名に設定された「term」属性を持つカテゴリを含めます。

<category scheme="http://schemas.google.com/sites/2008#folder" term="FolderName">

ウェブ アタッチメント

ウェブ添付ファイルは、特殊な種類の添付ファイルです。基本的には、ウェブ上の他のファイルへのリンクであり、ファイルキャビネットのリスティングに追加できます。この機能は、Google サイトの UI の [URL でファイルを追加] アップロード方法に類似しています。

: ウェブ添付ファイルはファイル キャビネットでのみ作成できます。他の種類のページにアップロードすることはできません。

この例では、ID FILECABINET_ENTRY_ID で参照されるファイル キャビネットの下に webattachment を作成します。タイトルと説明(省略可)はそれぞれ「GoogleLogo」と「nice colors」に設定されています。

POST /feeds/content/domainName/siteName HTTP/1.1
Host: sites.google.com
GData-Version: 1.4
Authorization: <your authorization header here>
Content-Type: application/atom+xml
Content-Length: 531

<entry xmlns="http://www.w3.org/2005/Atom">
  <category scheme="http://schemas.google.com/g/2005#kind"
          term="http://schemas.google.com/sites/2008#webattachment" label="webattachment"/>
  <link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml"
        href="https://sites.google.com/feeds/content/domainName/siteName/FILECABINET_ENTRY_ID"/>
  <title>GoogleLogo</title>
  <summary>nice colors</summary>
  <content type="image/gif" src="http://www.google.com/images/logo.gif"></content>
</entry>

POST は、ユーザーのファイルキャビネットに 'http://www.google.com/images/logo.gif' の画像を指すリンクを作成します。

トップへ戻る



コンテンツの更新

任意のページのメタデータ(タイトル、pageName など)とページ コンテンツは、edit リンクへの単一の PUT リクエストで編集できます。リクエストの本文には、更新されたページを記述する Atom エントリを含める必要があります。このルールの例外は添付ファイル エントリです。この場合、エントリは添付ファイルのメタデータの更新にのみ使用できます。添付ファイルの内容を変更するには、添付ファイルの edit-media リンクに対する PUT リクエストの本文として、生データを指定します。MIME マルチパート リクエストを使用すると、メタデータと添付ファイルの内容を同時に更新することもできます。

更新によって別のクライアントの変更が上書きされないようにするには、元のエントリの ETag 値を含めます。これを行うには、HTTP If-Match ヘッダーで ETag 値を指定するか、更新されたエントリに元のエントリの gd:etag 属性を含めます。元のエントリの ETag 値を特定するには、<entry> 要素の gd:etag 属性を調べます。メディア エントリの場合、メディアの ETag は edit-media リンクの gd:etag 属性で取得できることがあります。

取得後に他のユーザーがエントリを更新したかどうかに関係なくエントリを更新する場合は、If-Match: * を使用し、ETag を含めないでください。ETag について詳しくは、Google Data APIs リファレンス ガイドをご覧ください。

アイテムのメタデータまたは HTML コンテンツの更新

エントリのメタデータまたは HTML コンテンツを更新するには、エントリの edit リンクに HTTP PUT を送信します。

次の例は、次の変更で listpage エントリ(ID ENTRY_ID で表される)を更新する方法を示しています。

  • タイトルが「Updated Content」に変更されます。
  • 更新された HTML コンテンツ
  • リストの最初の列の見出しが [所有者] に更新される
  • ページの URL パスが <sites:pageName> 要素によって変更される
PUT /feeds/content/domainName/siteName/ENTRY_ID
Host: sites.google.com
GData-Version: 1.4
Authorization: <your authorization header here>
Content-Length: 816
Content-Type: application/atom+xml

<entry xmlns="http://www.w3.org/2005/Atom" xmlns:sites="http://schemas.google.com/sites/2008"
    xmlns:gs="http://schemas.google.com/spreadsheets/2006" xmlns:gd="http://schemas.google.com/g/2005"
    gd:etag="W/&quot;CEEBRn0ymA9WxJWEUw.&quot;">
  <category scheme="http://schemas.google.com/g/2005#kind"
      term="http://schemas.google.com/sites/2008#listpage" label="listpage"/>
  <title>Updated Title</title>
  <content type="xhtml">
    <div xmlns="http://www.w3.org/1999/xhtml">Updated Content</div>
  </content>
  <gs:worksheet name="listpage"/>
  <gs:header row="1"/>
  <gs:data startRow="2">
    <gs:column index="A" name="Owner"/>
    <gs:column index="B" name="Description"/>
    <gs:column index="C" name="Completed"/>
  </gs:data>
  <sites:pageName>newPagePath</sites:pageName>
</entry>

注: エントリ(サーバーから返される)には、上記の例よりも多くの要素が含まれます。

添付ファイルの内容を置き換える

添付ファイルの内容を置き換えても、メタデータは変更されない例を次に示します。リクエストに新しいコンテンツが含まれているため、添付ファイル エントリの edit-media リンクが使用されます。

PUT /feeds/media/content/domainName/siteName/ATTACHMENT_ENTRY_ID
Host: sites.google.com
GData-Version: 1.4
Authorization: <your authorization header here>
Content-Length: 70581
Content-Type: application/msword

... doc contents here ...

添付ファイルのメタデータとコンテンツの更新

添付ファイルのメタデータとコンテンツを同時に更新する例を次に示します。添付ファイルの名前が「新しいタイトル」に更新され、その内容が .zip ファイルの内容に置き換えられます。リクエストに新しいファイル コンテンツが含まれているため、添付ファイル エントリの edit-media リンクが使用されます。

メタデータの ETag を含めると、メディア コンテンツの暗黙的な If-Match も提供されることに注意してください。これは、メディア コンテンツが更新されると、メタデータの ETag が変更されるためです。

PUT /feeds/media/content/domainName/siteName/ATTACHMENT_ENTRY_ID
Host: sites.google.com
GData-Version: 1.4
Authorization: <your authorization header here>
Content-Type: multipart/related; boundary="END_OF_PART"
--END_OF_PART
Content-Type: application/atom+xml

<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005" gd:etag="BxAaTxRZAyp7ImBq">
  <link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml"
        href="https://sites.google.com/feeds/content/domainName/siteName/ATTACHMENT_ENTRY_ID"/>
  <title>New Title</title>
</entry>

--END_OF_PART
Content-Type: application/zip

... zip contents here ...

--END_OF_PART

トップへ戻る



コンテンツの削除

Google サイトからアイテムを削除するには、まずエントリを取得し、次にエントリの edit URL に DELETE リクエストを送信します。これは、アイテムのメタデータまたは HTML コンテンツを更新するときに使用する URL と同じです。

DELETE /feeds/content/domainName/siteName/ENTRY_ID
Host: sites.google.com
GData-Version: 1.4
Authorization: <your authorization header here>
If-Match: <ETag or * here>

エントリが正常に削除されると、サーバーは HTTP 200 OK で応答します。

取得後に別のクライアントによって変更されたエントリを削除しないようにするには、元のエントリの ETag 値を含む HTTP If-Match ヘッダーを含めます。元のエントリの ETag 値は、<entry> 要素の gd:etag 属性を調べることで確認できます。

取得後に他のユーザーが更新したかどうかに関係なくエントリを削除する場合は、If-Match: * を使用し、ETag を含めないでください。(この場合、エントリを削除する前に取得する必要はありません)。

ETag について詳しくは、Google Data APIs リファレンス ガイドをご覧ください。

トップへ戻る



添付ファイルをダウンロードする

添付ファイル エントリを取得したら、エントリの <content> src リンクに認証済み HTTP GET を送信して、ファイルをダウンロードできます。PDF のコンテンツ リンクの例:

<content type="application/pdf"
  src="http://502377765-a-google-com-s-sites.googlegroups.com/feeds/media/content/domainName/siteName/678942036"/>

トップへ戻る

ACL フィード

共有権限(ACL)の概要

ACL フィードの各 ACL エントリは、特定のエンティティ(ユーザー、ユーザーのグループ、ドメイン、またはデフォルトのアクセス(公開サイト))のアクセスロールを表します。エントリは、明示的なアクセス権を持つエンティティに対してのみ表示されます。Google サイトの UI の共有画面の [アクセス権を持つユーザー] パネルに表示されるメールアドレスごとに 1 つのエントリが表示されます。そのため、サイトへの暗黙的なアクセス権がある場合でも、ドメイン管理者は表示されません。

ロール

role 要素は、エンティティが持つことができるアクセスレベルを表します。gAcl:role 要素には次の 4 つの値を使用できます。

  • reader - 閲覧者(読み取り専用アクセス権と同等)。
  • writer - コラボレーター(読み取り/書き込みアクセス権と同等)。
  • owner - 通常はサイト管理者(読み取り/書き込みアクセス権に相当)。

スコープ

スコープ要素は、このアクセスレベルを持つエンティティを表します。gAcl:scope 要素には次の 5 つのタイプがあります。

  • user - メールアドレスの値(例: "user@gmail.com")。
  • group - Google グループのメールアドレス(例: group@domain.com)。
  • domain - Google Workspace ドメイン名(例: domain.com)。
  • invite - サイトに招待されたが、まだサイトの ACL に追加されていないユーザー。(gdata 1.3 以下が指定されている場合は使用できません)。
  • default - タイプ「default」のスコープは 1 つのみで、値はありません(例: <gAcl:scope type="default">)。この特定のスコープは、パブリック サイトでユーザーがデフォルトで持つアクセス権を制御します。

: ドメインの gAcl:role 値を「オーナー」アクセスに設定することはできません。リーダーまたは書き込み専用に設定できます。

「invite」スコープについて。

API は、Google アカウントをまだ持っていないユーザーを 1 人以上 ACL に追加すると、招待スコープを返します。API は、招待されたユーザーが招待を受け入れるために必要なトークンが埋め込まれた URL を返します。

この招待方法では、使用するメールアドレスを事前に知らなくても、Google 以外のユーザーを招待できます。ユーザーが埋め込みトークンを含む招待 URL をクリックする限り、任意のメールアドレスを使用してアクセスに登録できます。また、複数のユーザーがこの URL を使用して招待を承諾できるため、1 人のユーザーまたはユーザー グループを招待する場合に便利です。

注: 「invite」スコープは、gdata バージョン 1.4 以降でのみ使用できます。1.3 以下を明示的に指定している場合は、この方法は機能しません。

ACL フィードの取得

ACL フィードは、サイトの共有権限を制御するために使用できます。次の URI からアクセスできます。

https://sites.google.com/feeds/acl/site/domainName/siteName
フィード パラメータ説明
domainNamesite」または G Suite でホストされているドメインのドメイン(例: example.com)。
siteNameサイトのウェブスペース名。サイトの URL(例: myCoolSite)で確認できます。

サイトフィードの各エントリには、このフィードへのリンクが含まれています。

 <link rel="http://schemas.google.com/acl/2007#accessControlList" type="application/atom+xml"
      href="https://sites.google.com/feeds/acl/site/domainName/siteName"/>

サイトの共有権限を取得するには、ACL フィード URI に HTTP GET を送信します。

GET /feeds/acl/site/domainName/siteName HTTP/1.1
Host: sites.google.com
GData-Version: 1.4
Authorization: <your authorization header here>

サーバーは 200 OK と ACL エントリのフィードで応答します。

<feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/"
    xmlns:gAcl="http://schemas.google.com/acl/2007" xmlns:sites="http://schemas.google.com/sites/2008"
    xmlns:gs="http://schemas.google.com/spreadsheets/2006" xmlns:dc="http://purl.org/dc/terms"
    xmlns:batch="http://schemas.google.com/gdata/batch" xmlns:gd="http://schemas.google.com/g/2005"
    xmlns:thr="http://purl.org/syndication/thread/1.0">
<id>https://sites.google.com/feeds/acl/site/domainName/siteName</id>
<updated>2009-12-03T22:01:05.963Z</updated>
<category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/acl/2007#accessRule"/>
<title>Acl</title>
<link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml"
    href="https://sites.google.com/feeds/acl/site/domainName/siteName"/>
<link rel="http://schemas.google.com/g/2005#post" type="application/atom+xml"
    href="https://sites.google.com/feeds/acl/site/domainName/siteName"/>
<link rel="self" type="application/atom+xml"
    href="https://sites.google.com/feeds/acl/site/domainName/siteName"/>
<generator version="1" uri="http://sites.google.com">Google Sites</generator>
<openSearch:startIndex>1</openSearch:startIndex>
<entry>
  <id>https://sites.google.com/feeds/acl/site/domainName/siteName/user%3AuserA%40gmail.com</id>
  <updated>2009-12-03T22:01:05.963Z</updated>
  <app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-03T22:01:05.963Z</app:edited>
  <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/acl/2007#accessRule"/>
  <link rel="self" type="application/atom+xml"
      href="https://sites.google.com/feeds/acl/site/domainName/siteName/user%3AuserA%40google.com"/>
  <link rel="edit" type="application/atom+xml"
      href="https://sites.google.com/feeds/acl/site/domainName/siteName/user%3AuserA%40google.com"/>
  <gAcl:scope type="user" value="userA@google.com"/>
  <gAcl:role value="owner"/>
</entry>
<entry>
  <id>https://sites.google.com/feeds/acl/site/domainName/siteName/user%3AuserB%40gmail.com</id>
  <updated>2009-12-03T22:01:05.963Z</updated>
  <app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-03T22:01:05.963Z</app:edited>
  <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/acl/2007#accessRule"/>
  <link rel="self" type="application/atom+xml"
      href="https://sites.google.com/feeds/acl/site/domainName/siteName/user%3AuserB%40gmail.com"/>
  <link rel="edit" type="application/atom+xml"
      href="https://sites.google.com/feeds/acl/site/domainName/siteName/user%3AuserB%40gmail.com"/>
  <gAcl:scope type="user" value="userB@gmail.com"/>
  <gAcl:role value="writer"/>
</entry>
<entry>
  <id>https://sites.google.com/feeds/acl/site/domainName/siteName/user%3AuserC%40gmail.com</id>
  <updated>2009-12-03T22:01:05.963Z</updated>
  <app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-03T22:01:05.963Z</app:edited>
  <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/acl/2007#accessRule"/>
  <link rel="self" type="application/atom+xml"
      href="https://sites.google.com/feeds/acl/site/domainName/siteName/user%3AuserC%40gmail.com"/>
  <link rel="edit" type="application/atom+xml"
      href="https://sites.google.com/feeds/acl/site/domainName/siteName/user%3AuserC%40gmail.com"/>
  <gAcl:scope type="user" value="userC@gmail.com"/>
  <gAcl:role value="reader"/>
</entry>
...
</feed>

トップへ戻る

サイトを共有する

ACL フィードは GETPOSTPUT リクエストを受け入れます。新しいロールを ACL フィードに挿入するには、サイトの ACL フィードに POST リクエストを発行します。

: 特定の共有 ACL は、ドメインでそのような権限が許可されている場合にのみ設定できます(例: G Suite ドメインでドメイン外の共有が有効になっている場合など)。

この例では、新しい共同編集者(ライター)をサイトに追加します。

POST /feeds/acl/site/domainName/siteName HTTP/1.1
Host: sites.google.com
GData-Version: 1.4
Authorization: <your authorization header here>

<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gAcl='http://schemas.google.com/acl/2007'>
  <category scheme='http://schemas.google.com/g/2005#kind'
    term='http://schemas.google.com/acl/2007#accessRule'/>
  <gAcl:role value='writer'/>
  <gAcl:scope type='user' value='new_writer@example.com'/>
</entry>

挿入が成功すると、201 Created と新しいエントリが返されます。

<entry>
  <id>https://sites.google.com/feeds/acl/site/domainName/siteName/user%3Anew_writer%40example.com</id>
  <updated>2009-12-03T22:01:05.963Z</updated>
  <app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-03T22:01:05.963Z</app:edited>
  <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/acl/2007#accessRule"/>
  <link rel="self" type="application/atom+xml"
      href="https://sites.google.com/feeds/acl/site/domainName/siteName/user%3Anew_writer%40example.com"/>
  <link rel="edit" type="application/atom+xml"
      href="https://sites.google.com/feeds/acl/site/domainName/siteName/user%3Anew_writer%40example.com"/>
  <gAcl:role value='writer'/>
  <gAcl:scope type='user' value='new_writer@example.com'/>
</entry>

「invite」スコープを使用してユーザーを招待する

Google アカウントを持っていないユーザーを追加すると、API は招待するユーザーに提供する必要がある URL を返します。URL をクリックすると、既存のアカウントでログインするか、新しいアカウントを作成してサイトにアクセスできます。

招待が成功すると、201 Created と、ユーザーに渡す必要のある URL を含む新しいエントリが返されます。

<entry>
  <id>https://sites.google.com/feeds/acl/site/domainName/siteName/user%3Anew_invite%40example.com</id>
  <updated>2009-12-03T22:01:05.963Z</updated>
  <app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-03T22:01:05.963Z</app:edited>
  <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/acl/2007#accessRule"/>
  <link rel="http://schemas.google.com/sites/2008#invite" type="text/html"href="domainName/siteName?invite=inviteToken"/>
  <link rel="self" type="application/atom+xml"
      href="https://sites.google.com/feeds/acl/site/domainName/siteName/user%3Anew_invite%40example.com"/>
  <link rel="edit" type="application/atom+xml"
      href="https://sites.google.com/feeds/acl/site/domainName/siteName/user%3Anew_invite%40example.com"/>
  <gAcl:role value='writer'/>
  <gAcl:scope type='invite' value='new_invite%40example.com'/>
</entry>

グループとドメインレベルの共有

サイトを 1 人のユーザーと共有する場合と同様に、Google グループまたは G Suite ドメイン全体でサイトを共有できます。必要な scope 値は次のとおりです。

グループのメールアドレスで共有する場合:

<gAcl:scope type="group" value="group@example.com"/>

ドメイン全体と共有する場合:

<gAcl:scope type="domain" value="example.com"/>

ドメイン単位での共有は、G Suite ドメインでのみ、サイトがホストされているドメインでのみサポートされます。たとえば、http://sites.google.com/a/domain1.com/siteA は、ドメイン 2.com ではなく、ドメイン 1.com とのみサイト全体を共有できます。G Suite ドメインでホストされていないサイト(http://sites.google.com/site/siteB など)は、ドメインを招待できません。

共有権限の変更

ACL エントリを更新するには、必要に応じてエントリを変更し、エントリの edit リンク(単なる <link> 要素で、その rel 属性が edit に設定されている)に HTTP PUT リクエストを発行します。前の例の場合、リンクは次のようになります。

<link rel='edit' type='application/atom+xml'
    href='https://sites.google.com/feeds/acl/site/domainName/siteName/user%3Anew_writer%40example.com'/>

次のスニペットは、new_writer@gmail.com のロールを「閲覧者」に変更します。

PUT /feeds/acl/site/domainName/siteName/user%3Anew_writer%40example.com HTTP/1.1
Host: sites.google.com
GData-Version: 1.4
Authorization: <your authorization header here>

<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gAcl='http://schemas.google.com/acl/2007'>
  <category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/acl/2007#accessRule'/>
  <gAcl:role value='reader'/>
  <gAcl:scope type='user' value='new_writer@gmail.com'/>
</entry>

共有権限を削除する

このユーザーの権限を削除するには、PUT リクエストで使用したのと同じ edit リンクに DELETE リクエストを発行します。

DELETE /feeds/acl/site/domainName/siteName/user%3Anew_writer%40example.com HTTP/1.1
Host: sites.google.com
GData-Version: 1.4
Authorization: <your authorization header here>

サーバーは 200 OK を返します。

トップへ戻る

特別トピック

フィードまたはエントリを再度取得する

以前に取得したフィードまたはエントリを取得する場合は、前回取得したときから変更があった場合にのみリストまたはエントリを送信するようにサーバーに指示することで、効率を向上させることができます。

このような条件付き取得を行うには、HTTP If-None-Match ヘッダーを含む HTTP GET リクエストを送信します。ヘッダーで、リストまたはエントリの ETag を指定します。これは、<feed> 要素または <entry> 要素の gd:etag 属性で確認できます。

サイトフィードの使用例:

GET /feeds/site/domainName/myOtherTestSite/
GData-Version: 1.4
If-None-Match: W/"Ck8GQXk7fil7ImA9WxNSFk0."

サーバーは、このリクエストを受信すると、リクエストしたアイテムの ETag が指定した ETag と同じかどうかを確認します。ETag が一致する場合、アイテムは変更されていません。サーバーは HTTP 304 Not Modified ステータス コードまたは HTTP 412 Precodition Failed ステータス コードを返します。これらのステータス コードは、すでに取得したアイテムが最新であることを示します。

ETag が一致しない場合、アイテムは前回リクエストされてから変更されているため、サーバーはアイテムを返します。

ETag について詳しくは、Google Data APIs リファレンス ガイドをご覧ください。

バッチ処理

バッチ リクエストを使用すると、クライアントは各オペレーションを個別に送信するのではなく、1 つのリクエストで複数のオペレーションを実行できます。

サーバーは、リクエストされた変更を可能な限り実行し、各オペレーションの成功または失敗を評価するために使用できるステータス情報を返します。Google Data API のバッチ処理の詳細については、Google Data API を使用したバッチ処理をご覧ください。

バッチ フィード内のすべてのオペレーションには、挿入オペレーションを除き、<id> 要素があります。この要素は、コンテンツ フィードの更新、削除、クエリを行う際に通常使用するリクエスト URL と同じです。たとえば、編集を更新する場合は、<id> を該当するエントリの edit リンクに設定します。ターゲット エントリの識別に使用されます。新しいエントリには、まだ作成されていないため、<id> 要素はありません。代わりに、<batch:id> で文字列値を定義できます。この値はサーバーのレスポンスで返され、対応するエントリの検索に使用されます。

バッチ リクエストを行うには、バッチ フィードを作成し、フィードのバッチリンクに HTTP POST を送信します。

<link rel="http://schemas.google.com/g/2005#batch" type="application/atom+xml"
    href="https://sites.google.com/feeds/content/site/siteName/batch"/>

次の例は、ウェブページ エントリのクエリ、挿入、更新、削除を行う方法を示しています。

POST /feeds/content/site/siteName/batch HTTP/1.1
Host: sites.google.com
Accept: */*
If-Match: *
GData-Version: 1.4
Authorization: <your authorization header here>

<feed xmlns="http://www.w3.org/2005/Atom" xmlns:sites="http://schemas.google.com/sites/2008"
      xmlns:gd="http://schemas.google.com/g/2005" xmlns:batch='http://schemas.google.com/gdata/batch'>
  <entry>
    <id>https://sites.google.com/feeds/content/site/siteName/ENTRY_ID1</id>
    <batch:operation type="query"/>
  </entry>
  <entry>
    <batch:id>1</batch:id>
    <batch:operation type='insert'/>
    <category scheme="http://schemas.google.com/g/2005#kind"
        term="http://schemas.google.com/sites/2008#webpage" label="webpage"/>
    <title>New Webpage1</title>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">HTML body goes here</div>
    </content>
  </entry>
  <entry gd:etag="&quot;YDgpeyI.&quot;">
    <id>https://sites.google.com/feeds/content/site/siteName/ENTRY_ID2</id>
    <batch:operation type='update'/>
    <category scheme="http://schemas.google.com/g/2005#kind"
        term="http://schemas.google.com/sites/2008#webpage" label="webpage"/>
    <title>Updated Title for Webpage2</title>
    ...
    <batch:operaation type="update"/>
  </entry>
  <entry gd:etag="&quot;YassseyI.&quot;">
    <id>https://sites.google.com/feeds/content/site/siteName/ENTRY_ID3</id>
    <batch:operation type='delete'/>
  </entry>
</feed>

返されるフィードには、オペレーションごとに 1 つの結果エントリが含まれます。

 
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/"
    xmlns:sites="http://schemas.google.com/sites/2008" xmlns:gs="http://schemas.google.com/spreadsheets/2006"
    xmlns:dc="http://purl.org/dc/terms" xmlns:batch="http://schemas.google.com/gdata/batch"
    xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0">
<id>https://sites.google.com/feeds/content/site/siteName/ENTRY_ID1</id>
<updated>2009-11-10T22:44:08.369Z</updated>
<title>Batch Feed</title>
<entry gd:etag="&quot;YDgpsdfeyI.&quot;">
  <id>https://sites.google.com/feeds/content/site/siteName/ENTRY_ID1</id>
  <published>2009-08-31T04:42:45.251Z</published>
  <updated>2009-10-25T22:46:13.729Z</updated>
  <app:edited xmlns:app="http://www.w3.org/2007/app">2009-10-25T22:46:13.671Z</app:edited>
  <category scheme="http://schemas.google.com/g/2005#kind"
      term="http://schemas.google.com/sites/2008#webpage" label="webpage"/>
  <title>Page Title</title>
  ...
  <batch:status code="200" reason="Success"/>
  <batch:operation type="query"/>
</entry>
<entry gd:etag="&quot;YDsseyI.&quot;">
  <id>https://sites.google.com/feeds/content/site/siteName/ENTRY_ID4</id>
  <published>2009-11-10T22:44:08.531Z</published>
  <updated>2009-11-10T22:44:08.560Z</updated>
  <app:edited xmlns:app="http://www.w3.org/2007/app">2009-11-10T22:44:08.531Z</app:edited>
  <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#webpage" label="webpage"/>
  <title>New Webpage1</title>
  <content type="xhtml">
    <div xmlns="http://www.w3.org/1999/xhtml">
    <table cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox">
      <tbody>
        <tr>
          <td class="sites-layout-tile sites-tile-name-content-1">
            <div>HTML body goes here</div>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</content>
...
<batch:id>1</batch:id>
<batch:status code="201" reason="Created"/>
<batch:operation type="insert"/>
</entry>
<entry gd:etag="&quot;YDkpeyI.&quot;">
  <id>https://sites.google.com/feeds/content/site/siteName/ENTRY_ID2</id>
  <updated>2009-11-10T22:44:09.296Z</updated>
  <title>Updated Title for Webpage2</title>
  ...
  <sites:pageName>updated-title-for-webpage2</sites:pageName>
  <sites:revision>5</sites:revision>
  <batch:status code="200" reason="Success"/>
  <batch:operation type="update"/>
</entry>
<entry>
  <id>https://sites.google.com/feeds/content/site/siteName/ENTRY_ID3</id>
  <title>Deleted</title>
  <content>Deleted</content>
  <batch:status code="200" reason="Success"/>
  <batch:operation type="delete"/>
</entry>
</feed>

トップへ戻る