プロトコル ガイド

以前の Google Sites API を使用すると、アプリケーションが Google サイト内のコンテンツにアクセスし、公開、変更できるようになります。 さらに、最近のアクティビティのリストをリクエストしたり、変更履歴を取得したり、添付ファイルやファイルのアップロードとダウンロードを行ったりすることもできます。

オーディエンス

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

このドキュメントは、Google サイトとやり取りできるクライアント アプリケーションを作成するプログラマーを対象としています。 未加工の XML/HTTP を使用した Data API の基本的な操作の例を、説明とともにいくつか紹介します。このドキュメントを読んだら クライアント ライブラリを使用した API の操作について詳しくは、 言語固有の例は、左側のナビゲーション バーの他のガイドで確認できます。

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

リクエストの承認

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

認証プロトコルについて

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

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

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

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

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

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

Google Sites Data API で使用される OAuth 2.0 のスコープ情報は次のとおりです。

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

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

トップへ戻る

バージョンの指定

Google Sites Data API へのリクエストでは、必ずバージョン 1.4 を指定する必要があります。バージョン番号を指定するには、 GData-Version HTTP ヘッダーを使用します。

GData-Version: 1.4

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

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

トップへ戻る

サイト フィード

サイトフィードを使用すると、ユーザーが所有する Google サイト、または閲覧権限のある Google サイトを一覧表示できる 既存のサイトのタイトルも変更できます。G Suite ドメインの場合、ドメイン エイリアスを使用して できます。

サイトの一覧表示

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

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>

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

サイトが正常に作成されると、サーバーから 201 Created という応答が返されます。 レスポンス エントリには、サーバーによって追加された要素( site、サイトの 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 サイトの設定ページでオンになっている。
  • 移行元サイトで所有者として登録されていれば、別のドメインからサイトをコピーできます。

サイトのメタデータの更新

サイトのタイトルや概要を更新するには、HTTP PUT をサイトエントリの edit リンクに送信します。 たとえば、次の例では、前のサイトのタイトルを 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 のサイトには、ドメイン内のサイトを分類する際に役立つカテゴリのメタデータが含まれています。カテゴリのメタデータを追加または更新するには、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>

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

<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>

この例では、「Team Site」という 2 つのカテゴリを追加します。および「法務部」

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

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

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

サイトのウェブアドレスのマッピングを返すには、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 として表示されます。たとえば、上記の例で、 サイトを参照する 3 つの webAddressMapping がある http://sites.google.com/site/myOtherTestSite

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

: GET/POST/PUT 操作はすべて、作業時に with-mappings=true パラメータを指定する必要があります。 いくつかご紹介しますパラメータが存在しない場合、webAddressMapping はサイトエントリ(GET)で返されることも、考慮もされません。 エントリからマッピングを更新/削除(PUT)するときに、

マッピングを追加、更新、削除するには、新しいサイトを作成するときに、該当するリンクを指定、変更、削除します。 サイトのメタデータの更新。サイトフィードの URI には、with-mappings=true パラメータを含める必要があります。 注: アドレスのマッピングを更新するには、サイト管理者であるか、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>

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

トップへ戻る

アクティビティ フィード

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

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

https://sites.google.com/feeds/activity/domainName/siteName
フィード パラメータ説明
domainNamesite」または G Suite でホストされているドメインのドメイン(例: example.com)です。
siteNameサイトのウェブスペース名(例: 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サイトのウェブスペース名(例: 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 ヘッダーを送信し、取得したトークンを参照する必要があります。 リクエストの承認をご覧ください。

トップへ戻る

コンテンツ フィード

コンテンツの取得

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

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

その結果、サイト上のコンテンツ エントリの 1 ページ目をリストしたフィードが作成されます。フィード内の各エントリは、それぞれ異なるタイプのコンテンツ エントリを表しますが、 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 リファレンスをご覧ください。 従来の Google サイト 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 に含まれる名前に対応する URL が返されます。
<sites:revision>現在のリビジョン番号。

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

標準の Google Data API クエリ パラメータの一部を使用してコンテンツ フィードを検索できます。 従来の Google サイト API 向けの機能もあります。サポートされているパラメータの詳細と完全なリストについては、 リファレンス ガイド

特定のエントリの種類を取得する

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

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

複数のエントリタイプを返すには、各 kind を「,」で区切ります。この例では filecabinetlistpage 件のエントリ:

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

または、kind パラメータの代わりに標準形式を使用して、Google データの /-/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 パラメータを使用してその特定のページを取得できます。 この例では、次の URL にあるページが返されます: 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、 ページ見出しが「新しいウェブページのタイトル」である。つまり、URL の <atom:title>new-webpage-title に正規化されます。 ページの URL パスをカスタマイズするには、<sites:pageName> 要素を設定します。

この例では、ページ見出しが「File Storage」の新しい filecabinet を作成していますが、 URL http://sites.google.com/domainName/siteName/files で、 <sites:pageName> 要素を指定します。

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」はサーバーで受け入れられます

サブページの作成

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

この例では、エントリがある親お知らせページの下に、見出しが「announcement」の新しい announcement を作成します。 ID: PARENT_ENTRY_ID。ページ本文の 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>

ページ テンプレート

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

ページ テンプレートを作成する手順は、新しいアイテム/ページを作成する場合と同じです。 サブページの作成。違いは category を追加し、用語とラベルを 'http://schemas.google.com/g/2005#template' に設定する点です。 「template」を使用します。

この例では、新しい 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>

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

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

この例では、ファイル キャビネットを定義する既存のページ テンプレートから新しい 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> を定義するテンプレート( の入力が必要です。また、<content> 要素を含めると、サーバーによって拒否されます。

ファイルのアップロード

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

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

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

POST 本文は、ファイルの内容を次のテキストと組み合わせるために、MIME マルチパート リクエストにする必要があります。 アタッチメントのメタデータを含む <atom:entry><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">

ウェブ添付ファイル

ウェブ添付ファイルは特殊な種類の添付ファイルです。ウェブ上の他のファイルへのリンクです ファイルキャビネットのリスティングに追加できますこれは「URL でファイルを追加」機能に似ていますGoogle サイトの UI でアップロード方法を選択する。

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

この例では、ID FILECABINET_ENTRY_ID で参照されるファイル キャビネットの下に webattachment を作成します。 タイトルと説明(省略可)が「GoogleLogo」に設定されている「ナイスカラー」の 2 行になります

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」の画像を指すリンクを作成します。

トップへ戻る



コンテンツの更新

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

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

エントリの取得後に他のユーザーがそのエントリを更新したかどうかに関係なく、エントリを更新する場合は、次のコマンドを使用します。 If-Match: * であり、ETag は含めないでください。ETag の詳細については、このモジュールの Google Data API リファレンス ガイド

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

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

次の例では、listpage エントリ(ID ENTRY_ID で表されます)を次のように変更して更新します。

  • タイトルが「更新されたコンテンツ」に変更される
  • 更新された 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="Decription"/>
    <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 サイトからアイテムを削除するには、まずエントリを取得してから、DELETE を送信します リクエストをエントリの edit URL に送信します。これは、アイテムのメタデータや 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 API リファレンス ガイドをご覧ください。

トップへ戻る



添付ファイルのダウンロード

添付ファイルのエントリを取得したら、認証済みの HTTP GET をエントリの宛先に送信してファイルをダウンロードできます。 <content> ソースリンク。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 エントリは、特定のエンティティ(ユーザー、ユーザーのグループ、ドメイン、 デフォルト アクセス(一般公開サイト)でアクセスできます。明示的なアクセス権を持つエンティティに対してのみ、エントリが表示されます。1 つのエントリが表示されます。 [アクセス権を持つユーザー] のGoogle サイト UI の共有画面に表示されます。そのためドメイン管理者は表示されません 権限は付与されません。

ロール

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

  • reader — 閲覧者(読み取り専用アクセスと同等)。
  • writer — 共同編集者(読み取り/書き込みアクセスに相当)。
  • owner - 通常はサイト管理者(読み取り/書き込みアクセスに相当)。

スコープ

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

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

: ドメインに gAcl:role 値を指定することはできません。 「owner」に設定読み取りまたは書き込みのみ可能です

「招待」についてあります。

Google アカウントを持っていないユーザーを ACL に追加すると、API から招待スコープが返されます。API から埋め込みトークンを含む URL が返されます。招待を承諾してもらうには、このトークンを招待したユーザーに提供する必要があります。

この招待方法を使用すると、使用するメールアドレスが事前にわからない Google ユーザー以外のユーザーを招待できます。ユーザーはトークンが埋め込まれた招待 URL をクリックしさえすれば、任意のメールアドレスで登録してアクセスを申請できます。また、複数のユーザーがこの URL を使用して招待を承諾できる可能性があるため、1 人のユーザーまたはユーザー グループを招待する場合に便利です。

注: 「招待」はスコープは HMAC バージョン 1.4 以降でのみ使用できます。1.3 以下を明示的に指定した場合は機能しません。

ACL フィードの取得

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

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

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

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

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

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>

「招待」によるユーザーの招待スコープ

Google アカウントを持たないユーザーを追加すると、招待するユーザーに提供する必要のある URL が API から返されます。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 はドメイン全体を domain1.com とのみ共有でき、domain2.com とは共有できません。G Suite ドメインでホストされていないサイト(例: http://sites.google.com/site/siteB)は、ドメインを招待できません。

共有権限の変更

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

<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 のロールを「reader」に変更します。

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 GET リクエスト(HTTP を含む)を送信します。 If-None-Match ヘッダー。ヘッダーで、リストまたはエントリの ETag を指定します。ETag は <feed> 要素または <entry> 要素の gd:etag 属性。

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

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

サーバーはこのリクエストを受信すると、リクエストしたアイテムの ETag が 構成されます。ETag が一致した場合、アイテムは変更されておらず、サーバーは HTTP 304 Not Modified ステータス コードまたは HTTP 412 Precodition Failed ステータス コード。両方 ステータス コードは、取得したアイテムが最新の状態であることを示します。

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

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

バッチ処理

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

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

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

バッチ リクエストを行うには、バッチフィードを作成し、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>

トップへ戻る