Hướng dẫn về giao thức

API Google Sites cũ cho phép các ứng dụng của bạn truy cập, xuất bản và sửa đổi nội dung trong một Trang web tạo bằng Google Sites. Ngoài ra, ứng dụng của bạn có thể yêu cầu danh sách hoạt động gần đây, tìm nạp lịch sử sửa đổi cũng như tải lên/tải tệp đính kèm và tệp xuống.

Đối tượng

Tài liệu này giả định rằng bạn hiểu rõ các ý tưởng chung đằng sau giao thức Google Data API.

Tài liệu này dành cho các lập trình viên muốn viết ứng dụng khách có thể tương tác với Google Sites. Tài liệu này đưa ra một loạt ví dụ về các hoạt động tương tác cơ bản với API dữ liệu bằng XML/HTTP thô, kèm theo lời giải thích. Sau khi đọc tài liệu này, bạn có thể tìm hiểu thêm về cách tương tác với API thông qua thư viện ứng dụng của chúng tôi bằng cách đọc ví dụ theo ngôn ngữ cụ thể có trên các hướng dẫn khác trong thanh điều hướng bên trái.

Để tham khảo tài liệu trong hướng dẫn này, hãy xem hướng dẫn tham khảo.

Ủy quyền yêu cầu

Khi ứng dụng của bạn yêu cầu dữ liệu người dùng không công khai, ứng dụng phải bao gồm mã thông báo uỷ quyền. Mã này cũng giúp Google xác định ứng dụng của bạn.

Giới thiệu về giao thức cấp phép

Ứng dụng của bạn phải sử dụng OAuth 2.0 để cấp phép các yêu cầu. Chúng tôi không hỗ trợ giao thức cấp phép nào khác. Nếu ứng dụng của bạn sử dụng chức năng Đăng nhập bằng Google, thì Google sẽ giúp bạn xử lý một số bước trong quá trình cấp phép.

Cấp phép cho các yêu cầu bằng OAuth 2.0

Các yêu cầu gửi tới Google Sites Data API cho dữ liệu không công khai của người dùng phải được người dùng đã xác thực cấp phép.

Các chi tiết của quy trình cấp phép đối với OAuth 2.0 sẽ khác nhau đôi chút tuỳ thuộc vào loại ứng dụng bạn đang viết. Quy trình chung sau đây áp dụng cho tất cả các loại ứng dụng:

  1. Khi tạo ứng dụng của mình, bạn sẽ đăng ký ứng dụng bằng Google API Console. Sau đó, Google cung cấp thông tin bạn sẽ cần sau này, chẳng hạn như mã ứng dụng khách và mật khẩu ứng dụng khách.
  2. Kích hoạt Google Sites Data API trong Google API Console. (Nếu API không được liệt kê trong API Console, thì hãy bỏ qua bước này.)
  3. Khi cần quyền truy cập vào dữ liệu người dùng, ứng dụng sẽ yêu cầu Google cung cấp phạm vi truy cập cụ thể.
  4. Google hiển thị màn hình yêu cầu sự đồng ý cho người dùng để hỏi xem họ có cho phép ứng dụng của bạn yêu cầu một số dữ liệu của họ hay không.
  5. Nếu người dùng đồng ý, thì Google sẽ cấp cho ứng dụng của bạn một mã truy cập ngắn hạn.
  6. Sau đó, ứng dụng yêu cầu dữ liệu người dùng và đính kèm mã truy cập trong yêu cầu.
  7. Nếu xác định rằng yêu cầu của bạn và mã này là hợp lệ, Google sẽ trả về dữ liệu mà ứng dụng yêu cầu.

Một số quy trình cấp phép có các bước bổ sung khác, chẳng hạn như sử dụng mã làm mới để lấy mã truy cập mới. Để biết thông tin chi tiết về quy trình cho các loại ứng dụng khác nhau, hãy xem tài liệu về OAuth 2.0 của Google.

Dưới đây là thông tin về phạm vi của OAuth 2.0 cho Google Sites Data API:

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

Để yêu cầu quyền truy cập bằng OAuth 2.0, ứng dụng của bạn cần thông tin về mức truy cập, cũng như thông tin mà Google cung cấp khi bạn đăng ký ứng dụng của mình (chẳng hạn như mã ứng dụng khách và mật khẩu ứng dụng khách).

Trở lại đầu trang

Chỉ định phiên bản

Mọi yêu cầu bạn gửi tới Google Sites Data API phải chỉ định phiên bản 1.4. Để chỉ định số phiên bản, hãy dùng tiêu đề HTTP GData-Version:

GData-Version: 1.4

Ngoài ra, nếu không thể đặt tiêu đề HTTP, bạn có thể chỉ định v=1.4 làm tham số truy vấn trong URL. Tuy nhiên, Bạn nên ưu tiên tiêu đề HTTP nếu có thể.

Lưu ý: Thư viện ứng dụng tự động cung cấp tiêu đề phiên bản thích hợp, vì vậy, đừng sử dụng tham số truy vấn v=1.4 khi bạn đang sử dụng một thư viện ứng dụng.

Trở lại đầu trang

Nguồn cấp dữ liệu trang web

Bạn có thể dùng nguồn cấp dữ liệu trang web này để liệt kê những trang web tạo bằng Google Sites mà người dùng sở hữu hoặc có quyền xem và cũng sửa đổi tiêu đề của trang web hiện tại. Đối với các miền G Suite, bạn cũng có thể dùng miền này để tạo hoặc sao chép toàn bộ trang web.

Trang thông tin

Để liệt kê các trang web mà người dùng có quyền truy cập, hãy gửi yêu cầu GET đã xác thực đến URL sau:

https://sites.google.com/feeds/site/domainName
Thông số nguồn cấp dữ liệuMô tả
domainName"site" hoặc miền của miền do G Suite lưu trữ (ví dụ: example.com).

Phản hồi sẽ chứa một nguồn cấp dữ liệu với danh sách các trang web:

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>

Các trang web được liệt kê theo thứ tự bảng chữ cái.

Tạo trang web mới

Lưu ý: Tính năng này chỉ dành cho các miền G Suite.

Bạn có thể cấp phép cho các trang web mới bằng cách tạo một HTTP POST đến nguồn cấp dữ liệu trang web, ví dụ:

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>

Yêu cầu ở trên sẽ tạo một trang web Google mới có "phương tiện chặn" thuộc miền G Suite example.com. URL của trang web sẽ là http://sites.google.com/a/example.com/source-site/.

Nếu trang web được tạo thành công, máy chủ sẽ phản hồi bằng 201 Created. Mục nhập phản hồi sẽ chứa các phần tử được máy chủ thêm vào, chẳng hạn như một đường liên kết đến trang web, liên kết tới nguồn cấp dữ liệu ACL của trang web, tên, tiêu đề và tóm tắt của trang web.

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

Sao chép trang web

Lưu ý: Tính năng này chỉ dành cho các miền G Suite.

Bạn có thể sao chép trang web hiện có theo cách giống như cách tạo một trang web mới. Tuy nhiên, trong mục Atom của yêu cầu POST, có một <link>rel='source' trỏ đến nguồn cấp dữ liệu của trang web để sao chép. Bất kỳ trang web nào có được sao chép sẽ có liên kết này. Dưới đây là ví dụ về việc sao chép một trang web:

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>

Yêu cầu ở trên sẽ sao chép trang web tại http://sites.google.com/a/example.com/source-site/.

Điểm quan trọng:

  • Chỉ có thể sao chép các trang web và mẫu trang web mà người dùng đã xác thực sở hữu.
  • Bạn cũng có thể sao chép mẫu trang web. Trang web là mẫu nếu lệnh "Xuất bản trang web này dưới dạng mẫu" được chọn trong trang cài đặt Google Sites.
  • Bạn có thể sao chép một trang web từ một miền khác, trừ phi bạn được liệt kê là chủ sở hữu trên trang web nguồn.

Cập nhật siêu dữ liệu của trang web

Để cập nhật tiêu đề hoặc phần tóm tắt về một trang web, hãy gửi HTTP PUT đến đường liên kết edit của một mục nhập trang web. Ví dụ: ví dụ sau đây sẽ cập nhật tiêu đề của trang web trước thành New Test Site2 và cho 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>

Thêm danh mục

Lưu ý: Tính năng này chỉ dành cho các miền G Suite.

G Suite cho các trang web trong miền của bạn có chứa siêu dữ liệu về danh mục rất hữu ích cho việc phân loại các trang web trong miền của bạn. Để thêm hoặc cập nhật siêu dữ liệu danh mục, hãy gửi một HTTP PUT đến đường liên kết edit của mục nhập trang web có chứa thẻ category. Hãy xem dòng in đậm trong ví dụ sau:

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>

Ví dụ này chỉnh sửa một trang web hiện có và thêm danh mục "Trang web nhóm".

Bạn cũng có thể thêm nhiều danh mục bằng cách thêm các thẻ <category> bổ sung. Hãy xem các dòng in đậm trong ví dụ sau:

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>

Ví dụ này thêm hai danh mục: "Trang web nhóm" và "Phòng Pháp lý"

Ánh xạ địa chỉ web

Tính năng ánh xạ địa chỉ web cho phép người dùng Sites ánh xạ miền của riêng họ đến một trang web tạo bằng Google Sites. Ví dụ: http://www.mydomainsite.com có thể được sử dụng thay cho http://sites.google.com/a/domain.com/mysite. Tuỳ thuộc vào nơi lưu trữ trang web, bạn có thể sửa đổi bản đồ ánh xạ địa chỉ web của trang web. Hãy xem bài viết trên trung tâm trợ giúp của chúng tôi để biết thêm thông tin.

Tìm nạp các mục ánh xạ địa chỉ web của trang web

Để trả về mục ánh xạ địa chỉ web cho một trang web, hãy tìm nạp mục nhập/nguồn cấp dữ liệu trang web bằng tham số 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>

Các mối liên kết hiện có sẽ hiển thị dưới dạng link với rel='webAddressMapping'. Chẳng hạn như trong ví dụ trên có 3 webAddressMapping trỏ đến trang web này http://sites.google.com/site/myOtherTestSite.

Sửa đổi mối liên kết địa chỉ web

Lưu ý: Mọi thao tác GET/POST/PUT phải chỉ định tham số with-mappings=true khi hoạt động bằng cách liên kết địa chỉ web. Nếu không có tham số này, webAddressMapping sẽ không được trả về trong các mục nhập trang web (GET) hoặc được xem xét khi cập nhật/xoá (PUT) ánh xạ khỏi một mục nhập.

Để thêm, cập nhật hoặc xoá mối liên kết, chỉ cần chỉ định, thay đổi hoặc xoá đường liên kết như vậy khi tạo trang web mới hoặc cập nhật siêu dữ liệu của trang web. Tham số with-mappings=true phải được đưa vào URI của nguồn cấp dữ liệu trang web. Lưu ý: để cập nhật mục ánh xạ địa chỉ, bạn cần phải là quản trị viên trang web hoặc quản trị viên miền đối với trang web được lưu trữ trên G Suite.

Ví dụ: yêu cầu bên dưới cập nhật ánh xạ http://www.mysitemapping.com thành http://www.my-new-sitemapping.com, và xoá http://www.mysitemapping2.com bằng cách đưa đường liên kết ra khỏi mục:

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>

Lưu ý: Việc ánh xạ địa chỉ web cũng có thể được chỉ định vào thời điểm tạo/sao chép trang web.

Trở lại đầu trang

Danh sách hoạt động

Bạn có thể tìm nạp hoạt động gần đây của một Trang web (các thay đổi) bằng cách tìm nạp nguồn cấp dữ liệu hoạt động. Mỗi mục nhập trong nguồn cấp dữ liệu hoạt động chứa thông tin về thay đổi đã được thực hiện đối với Trang web.

Để truy vấn nguồn cấp dữ liệu hoạt động, hãy gửi một HTTP GET đến URL nguồn cấp dữ liệu hoạt động:

https://sites.google.com/feeds/activity/domainName/siteName
Thông số nguồn cấp dữ liệuMô tả
domainName"site" hoặc miền của miền do G Suite lưu trữ (ví dụ: example.com).
siteNameTên trang web của trang web của bạn; được tìm thấy trong URL của trang web (ví dụ: myCoolSite).

Ví dụ về yêu cầu và phản hồi:

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>

Lưu ý: Để truy cập vào nguồn cấp dữ liệu này, bạn phải là cộng tác viên hoặc chủ sở hữu của Trang web. Ứng dụng của bạn phải gửi đúng tiêu đề Authorization và tham chiếu đến mã thông báo nhận được trong phần Uỷ quyền cho yêu cầu.

Trở lại đầu trang

Nguồn cấp dữ liệu của bản sửa đổi

Để tìm nạp nhật ký sửa đổi cho bất kỳ mục nhập nội dung nào, hãy gửi một HTTP GET đến đường liên kết sửa đổi của mục nhập:

https://sites.google.com/feeds/revision/domainName/siteName/CONTENT_ENTRY_ID
Thông số nguồn cấp dữ liệuMô tả
domainName"site" hoặc miền của miền do G Suite lưu trữ (ví dụ: example.com).
siteNameTên trang web của trang web của bạn; được tìm thấy trong URL của trang web (ví dụ: myCoolSite).

Để tìm liên kết bản sửa đổi cho một trang/nhận xét/tệp đính kèm/danh sách mục nhất định, trước tiên hãy truy xuất mục nhập từ nguồn cấp nội dung bằng cách sử dụng CONTENT_ vượt_ID của nó. Mục nhập được truy xuất sẽ chứa <atom:link> cho nguồn cấp dữ liệu của bản sửa đổi. Ví dụ:

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

Ví dụ về yêu cầu và phản hồi:

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>

Lưu ý: Để truy cập vào nguồn cấp dữ liệu này, bạn phải là cộng tác viên hoặc chủ sở hữu của Trang web. Khách hàng của bạn phải gửi đúng tiêu đề Authorization và tham chiếu đến mã thông báo nhận được trong phần Uỷ quyền cho yêu cầu.

Trở lại đầu trang

Nguồn cấp nội dung

Truy xuất nội dung

Nguồn cấp nội dung liệt kê nội dung hiện tại của một Trang web. Gửi yêu cầu GET đã xác thực đến URL sau:

https://sites.google.com/feeds/content/domainName/siteName
Thông số nguồn cấp dữ liệuMô tả
domainName"site" hoặc miền của miền do G Suite lưu trữ (ví dụ: example.com).
siteNameTên trang web của trang web của bạn; được tìm thấy trong URL của trang web (ví dụ: myCoolSite).

Kết quả là một nguồn cấp dữ liệu liệt kê trang đầu tiên của các mục nội dung trên Trang web. Mỗi mục nhập trong nguồn cấp dữ liệu sẽ đại diện cho một loại mục nhập nội dung khác nhau, chẳng hạn như webpage, filecabinet, attachment, comment, v.v. Phần tử <category scheme="http://schemas.google.com/g/2005#kind"> xác định loại mục nhập. Xem hướng dẫn tham khảo để xem danh sách các giá trị kind hỗ trợ.

Lưu ý: Nguồn cấp dữ liệu này có thể yêu cầu hoặc không yêu cầu xác thực; tuỳ theo quyền chia sẻ của Trang web. Nếu Trang web không công khai, ứng dụng của bạn phải gửi đúng tiêu đề Authorization (như trong ví dụ trên) rồi tham chiếu mã thông báo nhận được trong phần Cho phép yêu cầu.

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>

Lưu ý: Đây chỉ là một vài kết quả đầu tiên. Để xem qua toàn bộ nguồn cấp nội dung, hãy làm theo "tiếp theo" trong nguồn cấp dữ liệu đường liên kết:

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

Để xem nội dung giải thích về các thành phần phổ biến đối với Atom, hãy xem tài liệu tham khảo về Giao thức dữ liệu của Google. Dưới đây là các phần tử có chức năng đo lường cụ thể của Sites API phiên bản cũ. Một số mục nhập loại nhất định sẽ có các thuộc tính bổ sung (không được liệt kê bên dưới), trong khi những người khác thì không. Ví dụ: mục nhập listitem có thể có phần tử <gs:field>, trong khi mục nhập webpage thì không.

Phần tửMô tả
<content ...>Văn bản bên trong là phần nội dung HTML của trang. Đối với một số mục nhập (ví dụ: tệp đính kèm), phần tử này sẽ chứa thuộc tính src trỏ đến tệp.
<link rel="alternate" ...>Đường liên kết đến trang hoặc một mục trong Google Sites.
<link rel="http://schemas.google.com/sites/2008#revision" ...>Thuộc tính href trỏ đến nguồn cấp dữ liệu của bản sửa đổi của mục nhập.
<link rel="http://schemas.google.com/sites/2008#parent" ...>Thuộc tính href trỏ đến mục nhập gốc của mục nhập.
<link rel="http://schemas.google.com/sites/2008#template" ...>Thuộc tính href trỏ đến trang mẫu của mục nhập.
<category scheme="http://schemas.google.com/g/2005#kind" ...>label là loại mục nhập.
<category term="http://schemas.google.com/g/2005#template" ...>label=template biểu thị mục nhập là một mẫu.
<gd:feedLink>Thuộc tính href trỏ đến phần tử con của mục gốc của mục nhập.
<sites:pageName>Tên trang web của trang; tương ứng với tên trong URL của trang.
<sites:revision>Số bản sửa đổi hiện tại.

Ví dụ về truy vấn nguồn cấp nội dung

Bạn có thể tìm kiếm nguồn cấp nội dung bằng cách sử dụng một số tham số truy vấn chuẩn của Google Data API và những thông tin dành riêng cho API Sites cũ. Để biết thêm thông tin chi tiết và danh sách đầy đủ các thông số được hỗ trợ, hãy xem Hướng dẫn tham khảo.

Truy xuất các loại mục nhập cụ thể

Để chỉ tìm nạp một loại mục nhập cụ thể, hãy sử dụng tham số kind. Ví dụ này chỉ trả về webpage mục nhập:

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

Để trả về nhiều loại mục nhập, hãy phân tách từng kind bằng dấu ','. Ví dụ này trả về filecabinetlistpage mục nhập:

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

Ngoài ra, bạn có thể sử dụng định dạng chuẩn cho truy vấn /-/category Dữ liệu của Google thay vì tham số kind:

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

Truy xuất mẫu trang

Ví dụ này chỉ trả về template trang:

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

Để trả về tất cả các loại mục nhập và bao gồm các trang template, hãy sử dụng:

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

Truy xuất trang theo đường dẫn

Nếu biết đường dẫn tương đối của một trang trong Google Sites, bạn có thể sử dụng tham số path để tìm nạp trang cụ thể đó. Ví dụ này trả về trang nằm ở http://sites.google.com/site/siteName/path/to/the/page:

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

Truy xuất tất cả các mục nhập trong trang gốc

Nếu biết mã mục nhập của một trang, bạn có thể sử dụng tham số parent để tìm nạp tất cả các mục nhập con của trang đó (nếu có):

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

Bao gồm cả bản nháp hoặc mục nhập đã bị xoá

Để thêm các mục nháp hoặc đã xoá, hãy dùng tham số include-drafts hoặc include-deleted tương ứng. Ví dụ này bao gồm các mục nhập nháp trong nguồn cấp nội dung:

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

Tìm kiếm toàn bộ văn bản

Để tìm kiếm trên toàn bộ nội dung của một trang web, hãy sử dụng tham số q để tìm kiếm toàn bộ văn bản:

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

Trở lại đầu trang



Sáng tạo nội dung

Bạn có thể tạo nội dung mới (trang web, trang danh sách, trang trang tổ chức tệp, trang thông báo, v.v.) bằng cách gửi một HTTP POST vào nguồn cấp nội dung:

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

Để biết danh sách các loại mục được hỗ trợ, hãy xem tham số kind trong Hướng dẫn tham khảo.

Tạo mục / trang mới

Ví dụ này sẽ tạo một webpage mới ở cấp cao nhất của Trang web, bao gồm một số IME cho phần nội dung của trang, và đặt tiêu đề tiêu đề thành 'Tiêu đề trang web mới':

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>

Nếu thành công, máy chủ sẽ phản hồi bằng 201 Created và một bản sao của mục nhập đó.

Tạo mục/trang trong đường dẫn URL tuỳ chỉnh

Theo mặc định, ví dụ trước sẽ được tạo trong URL http://sites.google.com/domainName/siteName/new-webpage-title và có tiêu đề trang là 'Tiêu đề trang web mới'. Tức là <atom:title> được chuẩn hoá thành new-webpage-title cho URL. Để tuỳ chỉnh đường dẫn URL của một trang, bạn có thể thiết lập phần tử <sites:pageName>.

Ví dụ này tạo một filecabinet mới với tiêu đề trang là "File Storage", nhưng lại tạo trang trong URL http://sites.google.com/domainName/siteName/files bằng cách chỉ định phần tử <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>

Máy chủ sử dụng các quy tắc ưu tiên sau đây để đặt tên cho đường dẫn URL của một trang:

  1. <sites:pageName>, nếu có. Phải đáp ứng a-z, A-Z, 0-9, -, _.
  2. <atom:title>, không được để trống nếu không có pageName. Chuẩn hoá là cắt + thu gọn khoảng trắng thành "-" và xoá những ký tự không khớp với a-z, A-Z, 0-9, -, _.

Ví dụ: 'Custom_Page2' đều được máy chủ chấp nhận.

Tạo trang con

Để tạo trang con (trang con) trong trang mẹ, hãy thêm <link rel="http://schemas.google.com/sites/2008#parent"> vào mục nhập Atom mới. Đặt thuộc tính href của đường liên kết thành đường liên kết tự liên kết của mục nhập gốc.

Ví dụ sau đây sẽ tạo một announcement mới với tiêu đề "thông báo", trong một trang thông báo chính có mục nhập Mã nhận dạng: PARENT_ENTRY_ID. Nội dung Squarespace cho phần thân trang cũng bao gồm:

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>

Mẫu trang

Tạo mẫu trang

Quy trình tạo mẫu trang cũng giống như tạo mục/trang mớitạo trang con.Điểm khác biệt là việc thêm category với từ khoá và nhãn được đặt thành "http://nguyes.google.com/g/2005#template" và "mẫu".

Ví dụ này sẽ tạo một mẫu webpage mới.

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>

Tạo trang từ mẫu

Tương tự như việc tạo mẫu trang, bạn có thể tạo bản sao trang mới từ mẫu bằng cách thêm <link> với rel='http://schema.google.com/sites/2008#template' chỉ đến đường liên kết tự liên kết của một mẫu trang.

Ví dụ này sẽ tạo một trang filecabinet mới từ một mẫu trang hiện có xác định một trang tổ chức tệp.

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>

Lưu ý: Mặc dù mẫu xác định <category>, bao gồm một mẫu trong mục nhập vẫn là bắt buộc. Ngoài ra, xin lưu ý rằng nếu bạn thêm phần tử <content>, máy chủ sẽ từ chối phần tử đó.

Đang tải tệp lên

Giống như trong Google Sites, API cho phép bạn tải tệp đính kèm lên trang tổ chức tệp và trang mẹ.

Để tải một tệp đính kèm lên thư mục mẹ, hãy gửi yêu cầu HTTP POST đến URL nguồn cấp nội dung:

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

Phần nội dung POST phải là một yêu cầu nhiều phần MIME để kết hợp nội dung tệp với <atom:entry> chứa siêu dữ liệu của tệp đính kèm. <atom:entry> phải tham chiếu đường liên kết tự liên kết của mục nhập gốc để chỉ định nơi tệp đính kèm sẽ được tạo. Xem phần Tạo trang con để biết thêm thông tin.

Đang tải tệp đính kèm lên

Dưới đây là ví dụ về cách tải tệp PDF lên trang tổ chức tệp có mã PARENT_ENTRY_ID. Tệp đính kèm sẽ được tạo với tiêu đề "Tệp PDF" và mô tả (không bắt buộc) là 'gói 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--

Nếu tải lên thành công, máy chủ sẽ phản hồi bằng một 201 Created và một bản sao của mục nhập tệp đính kèm mới tạo.

Tải tệp đính kèm lên thư mục

Để tải tệp đính kèm lên một thư mục hiện có trong filecabinet, hãy thêm một danh mục có "term" thuộc tính được đặt thành tên của thư mục:

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

Tệp đính kèm trên web

Tệp đính kèm web là các loại tệp đính kèm đặc biệt. Về cơ bản, chúng là các đường liên kết đến các tệp khác trên web mà bạn có thể thêm vào danh sách của trang tổ chức tệp. Tính năng này tương tự như tính năng "Thêm tệp theo URL" trong giao diện người dùng Google Sites.

Lưu ý: Bạn chỉ có thể tạo tệp đính kèm web trong trang tổ chức tệp. Bạn không thể tải các tệp này lên các loại trang khác.

Ví dụ này sẽ tạo một webattachment trong Filetệp được tham chiếu theo mã nhận dạng FILECABINET_ENTRY_ID. Tiêu đề và mô tả (không bắt buộc) của biểu trưng được đặt thành 'GoogleLogo' và 'màu đẹp'.

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 tạo một đường liên kết trong trang tổ chức tệp của người dùng trỏ đến hình ảnh tại "http://www.google.com/images/logo.gif".

Trở lại đầu trang



Cập nhật nội dung

Bạn có thể chỉnh sửa siêu dữ liệu (tiêu đề, tên trang, v.v.) và nội dung trang của bất kỳ trang nào bằng một yêu cầu PUT duy nhất cho đường liên kết edit. Nội dung yêu cầu phải chứa một mục Atom mô tả trang đã cập nhật. Trường hợp ngoại lệ đối với quy tắc này là một mục nhập tệp đính kèm, trong đó mục nhập này chỉ có thể dùng để cập nhật siêu dữ liệu của tệp đính kèm. Để thay đổi nội dung của tệp đính kèm, bạn chỉ cần đưa dữ liệu thô vào phần nội dung của yêu cầu PUT vào thuộc tính đường liên kết edit-media của tệp đính kèm. Bạn cũng có thể cập nhật cả siêu dữ liệu và nội dung tệp đính kèm cùng một lúc bằng cách sử dụng Yêu cầu nhiều phần MIME.

Để xác nhận rằng nội dung cập nhật của bạn không ghi đè nội dung thay đổi của một ứng dụng khác, hãy thêm giá trị ETag của mục nhập gốc. Bạn có thể thực hiện việc này bằng cách cung cấp giá trị ETag trong tiêu đề HTTP If-Match hoặc bằng cách thêm thuộc tính gd:etag của mục nhập gốc trong mục nhập đã cập nhật. Để xác định giá trị ETag của mục nhập gốc, hãy kiểm tra thuộc tính gd:etag của phần tử <entry>. Đối với các mục nội dung đa phương tiện, ETag của nội dung nghe nhìn có thể có trong thuộc tính gd:etag của đường liên kết edit-media.

Nếu bạn muốn cập nhật mục nhập bất kể người khác đã cập nhật mục nhập kể từ khi bạn truy xuất hay chưa, hãy sử dụng If-Match: * và không thêm ETag. Để biết thêm thông tin về ETag, hãy xem Hướng dẫn tham khảo về API Dữ liệu của Google.

Cập nhật siêu dữ liệu hoặc nội dung html của một mục

Để cập nhật siêu dữ liệu hoặc nội dung HTML của mục nhập, hãy gửi một HTTP PUT đến đường liên kết edit của mục nhập.

Sau đây là ví dụ về cách cập nhật mục nhập listpage (được biểu thị bằng mã nhận dạng ENTRY_ID) với các thay đổi sau:

  • Tiêu đề được sửa đổi thành "Nội dung cập nhật"
  • Nội dung HTML đã cập nhật
  • Tiêu đề cột đầu tiên của danh sách được cập nhật thành 'Chủ sở hữu'
  • Đường dẫn URL của trang được sửa đổi bằng phần tử <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>

Lưu ý: Mục nhập (do máy chủ trả về) sẽ chứa nhiều phần tử hơn ví dụ trên.

Thay thế nội dung của tệp đính kèm

Dưới đây là ví dụ về cách thay thế nội dung của tệp đính kèm nhưng giữ nguyên siêu dữ liệu của tệp. Vì yêu cầu chứa nội dung mới, Đường liên kết edit-media của mục nhập tệp đính kèm sẽ được sử dụng.

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

Cập nhật siêu dữ liệu + nội dung tệp đính kèm

Dưới đây là ví dụ về cách cập nhật cả siêu dữ liệu và nội dung của tệp đính kèm cùng một lúc. Tên tệp đính kèm sẽ được cập nhật thành "Tiêu đề mới" và nội dung của tệp này sẽ được thay thế bằng nội dung của tệp .zip. Vì yêu cầu chứa nội dung tệp mới, nên Đường liên kết edit-media của mục nhập tệp đính kèm đã được sử dụng.

Lưu ý rằng việc thêm ETag cho siêu dữ liệu cũng sẽ cung cấp If-Match ngầm ẩn cho nội dung đa phương tiện, vì mọi bản cập nhật đối với nội dung đa phương tiện khiến ETag của siêu dữ liệu thay đổi.

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

Trở lại đầu trang



Xoá nội dung

Để xoá một mặt hàng khỏi một trang web tạo bằng Google Sites, trước tiên, hãy truy xuất mục nhập đó rồi gửi DELETE yêu cầu đối với URL edit của mục nhập. Đây cũng là URL được dùng khi cập nhật siêu dữ liệu hoặc nội dung html của một mục.

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>

Nếu mục nhập đó đã được xoá thành công, máy chủ sẽ phản hồi bằng một HTTP 200 OK.

Nếu bạn muốn đảm bảo rằng bạn không xoá một mục nhập đã bị một ứng dụng khác thay đổi kể từ khi bạn truy xuất mục đó, hãy bao gồm Tiêu đề HTTP If-Match có chứa giá trị ETag của mục nhập gốc. Bạn có thể xác định giá trị ETag của mục nhập ban đầu bằng cách đang kiểm tra thuộc tính gd:etag của phần tử <entry>.

Nếu bạn muốn xoá mục nhập bất kể người khác có cập nhật mục nhập đó kể từ khi bạn truy xuất hay không, hãy sử dụng If-Match: * và không thêm ETag. (Trong trường hợp này, bạn không cần truy xuất mục nhập trước khi xoá.)

Để biết thêm thông tin về ETag, hãy xem Hướng dẫn tham khảo về API dữ liệu của Google.

Trở lại đầu trang



Đang tải tệp đính kèm xuống

Khi đã có mục nhập tệp đính kèm, bạn có thể tải tệp xuống bằng cách gửi một HTTP GET đã xác thực đến Đường liên kết src <content>. Ví dụ về đường liên kết đến nội dung của tệp PDF:

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

Trở lại đầu trang

Nguồn cấp dữ liệu ACL

Tổng quan về quyền chia sẻ (ACL)

Mỗi mục nhập ACL trong nguồn cấp dữ liệu ACL đại diện cho vai trò truy cập của một thực thể cụ thể, có thể là người dùng, nhóm người dùng, miền hoặc quyền truy cập mặc định (là một trang web công khai). Mục nhập sẽ chỉ hiển thị cho các thực thể có quyền truy cập rõ ràng – một mục nhập sẽ hiển thị cho từng địa chỉ email trong phần "Người dùng có quyền truy cập" trong màn hình chia sẻ của giao diện người dùng Google Sites. Do đó, quản trị viên miền sẽ không xuất hiện, ngay cả khi chúng có quyền truy cập ngầm ẩn vào một trang web.

Vai trò

Phần tử vai trò đại diện cho cấp truy cập mà một thực thể có thể có. Phần tử gAcl:role có thể có 4 giá trị:

  • người đọc — một người xem (tương đương với quyền chỉ có thể đọc).
  • người viết — một cộng tác viên (tương đương với quyền đọc/ghi).
  • owner – thường là quản trị viên trang web (tương đương với quyền truy cập đọc/ghi).

Phạm vi

Phần tử phạm vi đại diện cho thực thể có cấp truy cập này. Có 5 loại phần tử gAcl:scope:

  • người dùng — một giá trị địa chỉ email, ví dụ: "user@gmail.com".
  • group — một địa chỉ email của nhóm trên Google Groups, ví dụ: "group@domain.com".
  • domain – một tên miền của G Suite, ví dụ: "domain.com".
  • mời — người dùng đã được mời vào trang web nhưng chưa được thêm vào Danh sách kiểm soát quyền truy cập (ACL) cho trang web. (Không có nếu bạn chỉ định gdata 1.3 trở xuống.)
  • default — Chỉ có thể có một phạm vi thuộc loại "default", không có giá trị (ví dụ: <gAcl:scope type="default">). Phạm vi cụ thể này kiểm soát quyền truy cập của bất kỳ người dùng nào theo mặc định trên trang web công khai.

Lưu ý: Miền không được có giá trị gAcl:role đặt thành "chủ sở hữu" truy cập, họ chỉ có thể là độc giả hoặc tác giả.

Giới thiệu về tính năng "mời" phạm vi.

API sẽ trả về phạm vi lời mời khi bạn thêm một hoặc nhiều người dùng vào Danh sách kiểm soát quyền truy cập (ACL) chưa có Tài khoản Google. API sẽ trả về URL có mã thông báo được nhúng mà bạn phải cung cấp cho người dùng được mời để cho phép họ chấp nhận lời mời.

Phương thức mời này cho phép bạn mời người dùng không phải người dùng Google mà không cần biết trước địa chỉ email họ muốn sử dụng. Chỉ cần người dùng nhấp vào URL lời mời có mã thông báo được nhúng, họ có thể đăng ký truy cập bằng bất kỳ địa chỉ email nào họ muốn. Ngoài ra, nhiều người dùng có thể sử dụng URL này để chấp nhận lời mời, vì vậy, điều này có thể hữu ích nếu bạn mời một người dùng hoặc một nhóm người dùng.

Lưu ý: "Lời mời" phạm vi chỉ có trong gdata phiên bản 1.4 trở lên. Điều này sẽ không hoạt động nếu bạn chỉ định rõ ràng 1.3 trở xuống.

Truy xuất nguồn cấp dữ liệu ACL

Nguồn cấp dữ liệu ACL có thể được sử dụng để kiểm soát quyền chia sẻ của trang web và có thể truy cập được qua URI sau:

https://sites.google.com/feeds/acl/site/domainName/siteName
Thông số nguồn cấp dữ liệuMô tả
domainName"site" hoặc miền của miền do G Suite lưu trữ (ví dụ: example.com).
siteNameTên trang web của trang web của bạn; được tìm thấy trong URL của trang web (ví dụ: myCoolSite).

Lưu ý rằng mỗi mục nhập trong nguồn cấp dữ liệu trang web đều chứa một đường liên kết đến nguồn cấp dữ liệu này:

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

Để truy xuất quyền chia sẻ của trang web, hãy gửi và HTTP GET đến URI nguồn cấp dữ liệu ACL:

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

Máy chủ sẽ phản hồi bằng 200 OK và nguồn cấp dữ liệu gồm các mục nhập trong 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>

Trở lại đầu trang

Chia sẻ một trang web

Nguồn cấp dữ liệu ACL chấp nhận các yêu cầu GET, POSTPUT. Để chèn vai trò mới vào nguồn cấp dữ liệu ACL, bạn chỉ cần gửi yêu cầu POST tới nguồn cấp dữ liệu ACL của trang web.

Lưu ý: Một số ACL chia sẻ nhất định chỉ có thể hoạt động nếu miền được định cấu hình để cấp các quyền đó (ví dụ: nếu tính năng chia sẻ ra bên ngoài miền cho các miền G Suite đang bật, v.v.).

Ví dụ sau thêm một cộng tác viên (người viết) mới vào trang web:

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 và mục nhập mới sẽ được trả về khi chèn thành công:

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

Mời người dùng qua "lời mời" phạm vi

Nếu bạn thêm người dùng không có Tài khoản Google, thì API sẽ trả về URL mà bạn phải cung cấp cho người dùng mà bạn muốn mời. Sau khi nhấp vào URL, họ có thể truy cập vào trang web bằng cách đăng nhập bằng một tài khoản hiện có hoặc tạo một tài khoản mới.

Lời mời thành công sẽ trả về 201 Created và một mục mới có chứa URL bạn phải chuyển cho người dùng này:

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

Chia sẻ ở cấp Nhóm và cấp Miền

Tương tự như việc chia sẻ trang web với một người dùng, bạn có thể chia sẻ trang web qua Nhóm Google hoặc miền G Suite. Các giá trị scope cần thiết được liệt kê bên dưới.

Chia sẻ với một địa chỉ email nhóm:

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

Chia sẻ với toàn bộ miền:

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

Tính năng chia sẻ ở cấp miền chỉ được hỗ trợ cho các miền G Suite và chỉ cho miền mà trang web được lưu trữ. Ví dụ: http://sites.google.com/a/domain1.com/siteA chỉ có thể chia sẻ toàn bộ Trang web với domain1.com, chứ không thể chia sẻ với domain2.com. Các trang web không được lưu trữ trên một miền G Suite (ví dụ: http://sites.google.com/site/siteB) không thể mời miền.

Sửa đổi quyền chia sẻ

Để cập nhật mục nhập ACL, hãy sửa đổi mục nhập nếu cần và gửi yêu cầu HTTP PUT cho liên kết edit của mục nhập. Đây chỉ là phần tử <link> có "rel" được đặt thành "chỉnh sửa". Trong ví dụ trước, đường liên kết đó là:

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

Đoạn mã dưới đây thay đổi vai trò của new_writer@gmail.com thành "người đọc":

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>

Đang thu hồi quyền chia sẻ

Để thu hồi quyền của người dùng này, hãy gửi yêu cầu DELETE đến cùng một đường liên kết edit đã dùng cho yêu cầu PUT:

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>

Máy chủ sẽ phản hồi bằng 200 OK.

Trở lại đầu trang

Chủ đề đặc biệt

Truy xuất lại nguồn cấp dữ liệu hoặc mục nhập

Nếu muốn truy xuất nguồn cấp dữ liệu hoặc mục nhập mà bạn đã truy xuất trước đây, bạn có thể cải thiện hiệu quả bằng cách cho biết máy chủ để gửi danh sách hoặc mục nhập chỉ khi danh sách hoặc mục nhập đã thay đổi kể từ lần cuối bạn truy xuất.

Để thực hiện loại truy xuất có điều kiện này, hãy gửi yêu cầu HTTP GET bao gồm HTTP Tiêu đề If-None-Match. Trong tiêu đề, hãy chỉ định ETag của danh sách hoặc mục nhập mà bạn có thể tìm thấy trong thuộc tính gd:etag của phần tử <feed> hoặc <entry>.

Ví dụ về cách sử dụng nguồn cấp dữ liệu trang web:

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

Khi nhận được yêu cầu này, máy chủ sẽ kiểm tra xem mặt hàng bạn yêu cầu có cùng ETag như ETag mà bạn đã chỉ định. Nếu ETag khớp, thì mặt hàng không thay đổi và máy chủ trả về Mã trạng thái HTTP 304 Not Modified hoặc mã trạng thái HTTP 412 Precodition Failed. Cả hai cách trên mã trạng thái cho biết mặt hàng bạn truy xuất đã được cập nhật.

Nếu ETag không khớp, thì mặt hàng đã được sửa đổi kể từ lần gần đây nhất bạn yêu cầu và máy chủ trả về mặt hàng.

Để biết thêm thông tin về ETag, hãy xem Hướng dẫn tham khảo về API dữ liệu của Google.

Xử lý theo lô

Yêu cầu theo lô cho phép ứng dụng của bạn thực hiện nhiều thao tác trong một yêu cầu, thay vì gửi từng thao tác riêng lẻ.

Máy chủ sẽ thực hiện nhiều thay đổi được yêu cầu nhất có thể và trả về thông tin trạng thái mà bạn có thể sử dụng để đánh giá mức độ thành công hoặc thất bại của mỗi thao tác. Để biết thêm chi tiết về xử lý hàng loạt trong Google Data API, xem Xử lý hàng loạt bằng Google Data API

Mỗi thao tác trong nguồn cấp dữ liệu hàng loạt có một phần tử &lt;id&gt;, ngoại trừ thao tác chèn. Phần tử này giống với URL yêu cầu mà bạn thường dùng khi cập nhật, xoá hoặc truy vấn nguồn cấp nội dung. Ví dụ: nếu bạn đang cập nhật nội dung chỉnh sửa, hãy đặt &lt;id&gt; thành đường liên kết edit cho mục nhập liên quan. Mã này được dùng để xác định mục mục tiêu. Các mục nhập mới không có phần tử &lt;id&gt; vì chúng chưa được tạo. Thay vào đó, bạn có thể xác định một giá trị chuỗi trong &lt;batch:id&gt;. Giá trị này sẽ là được trả về trong phản hồi của máy chủ và dùng để tra cứu mục nhập tương ứng.

Để tạo yêu cầu hàng loạt, hãy tạo nguồn cấp dữ liệu hàng loạt và gửi một HTTP POST đến đường liên kết hàng loạt của nguồn cấp dữ liệu:

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

Ví dụ bên dưới cho thấy cách truy vấn, chèn, cập nhật và xoá một mục nhập trang web:

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>

Nguồn cấp dữ liệu được trả về sẽ chứa một mục kết quả cho mỗi toán tử:

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

Trở lại đầu trang