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 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 và tải lên/tải xuống tệp đính kèm và tệp.

Đối tượng người xem

Tài liệu này giả định rằng bạn đã hiểu các ý tưởng chung về 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 các ứng dụng khách có thể tương tác với Google Sites. Bài viết này cung cấp 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 nội dung 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 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ể trong các hướng dẫn khác ở thanh điều hướng bên trái.

Để tham khảo tài liệu trong hướng dẫn này, vui lòng 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 không công khai của người dùng, ứng dụng đó phải chứa 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

Yêu cầu đối với Google Sites Data API về dữ liệu người dùng không công khai 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 truy cập 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 một phiên bản

Mọi yêu cầu mà bạn gửi đến Google Sites Data API phải chỉ định phiên bản 1.4. Để chỉ định số phiên bản, hãy sử 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, tiêu đề HTTP sẽ được ưu tiên hơn nếu có thể.

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

Trở lại đầu trang

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

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

Trang web danh sách

Để 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ệuNội dung mô 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 cùng 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 HTTP POST vào 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 tạo bằng Google Sites mới có giao diện "phương tiện chặn" trong 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ử do máy chủ thêm vào, chẳng hạn như đường liên kết đến trang web, đường liên kết đến nguồn cấp dữ liệu ACL của trang web, tên trang web, tiêu đề và thông tin tóm tắt.

<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 một trang web hiện có theo cách giống như khi tạo một trang web mới. Tuy nhiên, trong mục Atom của yêu cầu POST, hãy thêm <link>rel='source' trỏ đến nguồn cấp dữ liệu trang web của trang web cần sao chép. Mọi trang web được sao chép sẽ có đường liên kết này. Sau đâ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/.

Lưu ý quan trọng:

  • Chỉ những trang web và mẫu trang web mà người dùng đã xác thực mới có thể sao chép.
  • Bạn cũng có thể sao chép mẫu trang web. Trang web được xem là một mẫu nếu chế độ cài đặt "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 trang web từ một miền khác, trong khi chờ 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 của một trang web, hãy gửi HTTP PUT đến đường liên kết edit của mục nhập trang web đó. Ví dụ sau đây sẽ cập nhật tiêu đề của trang web trước đó thành New Test Site2 và nội dung mô tả của trang web đó thành 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 dành cho các trang web thuộc miền của bạn có siêu dữ liệu danh mục 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 HTTP PUT đến đường liên kết edit của mục nhập trang web, trong đó có chứa thẻ category. 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. 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à "Bộ phận pháp lý"

Liên kết đị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ụ: bạn có thể sử dụng http://www.mydomainsite.com 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 mối liên kết địa chỉ web của trang web theo cách thủ công. Hãy xem bài viết trong trung tâm trợ giúp của chúng tôi để biết thêm thông tin.

Tìm nạp ánh xạ địa chỉ web của một 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'. Ví dụ: trong ví dụ trên, có ba webAddressMapping trỏ đến trang web http://sites.google.com/site/myOtherTestSite.

Sửa đổi ánh xạ địa chỉ web

Lưu ý: Tất cả các thao tác GET/POST/PUT đều phải chỉ định tham số with-mappings=true khi làm việc với 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á các liên kết (PUT) khỏi một mục nhập.

Để thêm, cập nhật hoặc xoá mối liên kết, bạn chỉ cần chỉ định, thay đổi hoặc xoá đường liên kết đó 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 nguồn cấp dữ liệu trang web. Lưu ý: để cập nhật mối liên kết đị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 trong trường hợp trang web được lưu trữ trên G Suite.

Ví dụ: yêu cầu bên dưới sẽ 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 rời khỏi mục liên kết:

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 ý: Bạn cũng có thể chỉ định mục ánh xạ địa chỉ web tại thời điểm tạo/sao chép một 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ác thay đổi) của một Trang web bằng cách tìm nạp nguồn cấp dữ liệu hoạt động. Mỗi mục trong nguồn cấp dữ liệu hoạt động chứa thông tin về một thay đổi đối với Trang web.

Để truy vấn nguồn cấp dữ liệu hoạt động, hãy gửi một GET HTTP đến URL của 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ệuNội dung mô 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 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 khách của bạn phải gửi tiêu đề Authorization chính xác và tham chiếu đến mã thông báo thu được trong phần Cấp quyền cho yêu cầu.

Trở lại đầu trang

Nguồn cấp dữ liệu 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ệuNội dung mô 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 bạn; được tìm thấy trong URL của trang web (ví dụ: myCoolSite).

Để tìm đường liên kết bản sửa đổi của một trang/nhận xét/tệp đính kèm/danh sách cụ thể, 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_ Connect_ID của nó. Mục nhập được truy xuất sẽ chứa một <atom:link> cho nguồn cấp dữ liệu 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. Ứng dụng của bạn phải gửi tiêu đề Authorization chính xác và tham chiếu đến mã thông báo thu được trong phần Cấp phép 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ệuNội dung mô 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 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 mục nhập 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 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. Hãy xem hướng dẫn tham khảo để biết 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ỳ thuộc vào quyền chia sẻ của Trang web. Nếu Trang web không công khai, khách hàng của bạn phải gửi tiêu đề Authorization chính xác (như trong ví dụ trên) và tham chiếu đến mã thông báo nhận được trong phần Cấp phép cho 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. Để chuyển qua toàn bộ nguồn cấp nội dung, hãy nhấp vào liên kết 'tiếp theo' của nguồn cấp dữ liệu:

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

Để biết nội dung giải thích về các thành phần phổ biến 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ó dữ liệu đo lường cụ thể đối với Sites API phiên bản cũ. Một số loại mục nhập sẽ có các thuộc tính bổ sung (không được liệt kê bên dưới), trong khi các loại khác thì không. Ví dụ: mục nhập listitem có thể chứa phần tử <gs:field>, trong khi mục nhập webpage thì không.

Phần tửNội dung 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ụ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 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 chính 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 này là một mẫu.
<gd:feedLink>Thuộc tính href trỏ đến phần tử con của phần tử mẹ của mục nhập.
<sites:pageName>Tên trang web; 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 API Dữ liệu của Google chuẩn và các tham số truy vấn 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 tham 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 cụ thể, hãy sử dụng tham số kind. Ví dụ này chỉ trả về các mục nhập webpage:

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ề các mục nhập filecabinetlistpage:

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 trên 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à đưa vào 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 trang web tạo bằng Google Sites, bạn có thể sử dụng tham số path để tìm nạp trang cụ thể đó. Ví dụ này sẽ trả về trang tại 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 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á

Để bao gồm các mục nháp hoặc đã xoá, hãy sử dụng tham số include-drafts hoặc include-deleted tương ứng. Dưới đây là ví dụ về 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 HTTP POST đến 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 nhập đượ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ụ sau đây sẽ tạo một webpage mới trong cấp cao nhất của Trang web, bao gồm một số ngôn ngữ viết tắt cho phần nội dung của trang và đặt 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 một 201 Created và 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 có tiêu đề trang là "File Storage" (Bộ nhớ tệp), 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 đườ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. Theo cách chuẩn hoá, bạn sẽ cắt bỏ + thu gọn khoảng trắng thành "*" và xoá các ký tự không khớp với a-z, A-Z, 0-9, -, _.

Ví dụ: "Custom_Page2" sẽ được máy chủ chấp nhận.

Tạo trang con

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

Ví dụ này sẽ tạo một announcement mới có tiêu đề "thông báo", bên dưới trang thông báo chính có mã mục nhập là PARENT_ENTRY_ID. Nội dung AndroidX cho phần nội dung 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 giống như quy trình tạo mục/trang mớitạo trang con.Điểm khác biệt là việc thêm category có thuật ngữ và nhãn được đặt tương ứng là "http://schemas.google.com/g/2005#template" và "template".

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ột mẫu bằng cách bao gồm <link> với rel='http://schemas.google.com/sites/2008#template' trỏ đến tự liên kết của mẫu trang.

Ví dụ này tạo trang filecabinet mới 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ột mẫu xác định <category> nhưng bạn vẫn bắt buộc phải có một mẫu trong mục nhập của mình. 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 gốc.

Để tải tệp đính kèm lên tài khoản 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 một <atom:entry> chứa siêu dữ liệu của tệp đính kèm. <atom:entry> phải tham chiếu đến đườ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. Hãy 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 một 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 phần mô tả (không bắt buộc) là "Gói nhân sự".

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 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ó thuộc tính "term" đượ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 trên web là 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 trang tổ chức tệp của mình. Tính năng này tương tự như phương pháp tải lên "Thêm tệp bằng 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 trên 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 tạo một webattachment trong trang tổ chức tệp được tham chiếu bằng mã nhận dạng FILECABINET_ENTRY_ID. Tiêu đề và nội dung mô tả (không bắt buộc) của biểu trưng được đặt lần lượt thành "GoogleBiểu trưng" và "màu sắc đẹ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 đối với đường liên kết edit. Nội dung yêu cầu phải chứa mục nhập Atom mô tả trang được 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 đính kèm, trong đó, bạn chỉ có thể sử dụng mục nhập này để 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 dưới dạng phần nội dung của yêu cầu PUT đối với đườ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 bản cập nhật của bạn không ghi đè những thay đổi của ứng dụng khác, hãy thêm giá trị ETag của mục nhập ban đầu. 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 đưa thuộc tính gd:etag của mục nhập gốc vào mục cập nhật. Để xác định giá trị ETag của mục nhập ban đầu, hãy kiểm tra thuộc tính gd:etag của phần tử <entry>. Đối với các mục nhập nội dung nghe nhìn, bạn có thể sử dụng ETag của nội dung nghe nhìn 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 kể từ khi bạn truy xuất hay chưa, hãy sử dụng If-Match: * và đừng thêm ETag. Để biết thêm thông tin về ETag, hãy xem hướng dẫn tham khảo 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ụ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 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ột mục 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 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 phần tử <sites:pageName> sửa đổi
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 không thay đổi siêu dữ liệu của tệp đó. Vì yêu cầu chứa nội dung mới, nên đường liên kết edit-media của mục đí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 và nội dung của tệp đính kèm

Dưới đây là ví dụ về cách cập nhật đồng thời siêu dữ liệu và nội dung của tệp đính kèm. Tên tệp đính kèm sẽ được cập nhật thành "New Title" và nội dung của tệp đính kèm 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 kèm sẽ được sử dụng.

Xin lưu ý rằng việc thêm ETag cho siêu dữ liệu cũng cung cấp If-Match ngầm cho nội dung đa phương tiện, vì mọi cập nhật đối với nội dung đa phương tiện đều 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ục khỏi Google Sites, trước tiên, hãy truy xuất mục đó rồi gửi yêu cầu DELETE đến URL edit của mục nhập đó. Đây là URL tương tự được sử dụng khi cập nhật siêu dữ liệu hoặc nội dung html của một mặt hàng.

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 xoá mục nhập 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ục đã bị một khách hàng khác thay đổi kể từ khi bạn truy xuất mục đó, hãy thêm tiêu đề HTTP If-Match chứa giá trị ETag của mục nhập ban đầu. Bạn có thể xác định giá trị ETag của mục nhập ban đầu bằng cách 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ập nhật mục này kể từ khi bạn truy xuất hay chưa, hãy sử dụng If-Match: * và đừ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 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ột mục đính kèm, bạn có thể tải tệp này xuống bằng cách gửi HTTP GET đã xác thực đến đường liên kết src <content> của mục nhập đó. Ví dụ về đường liên kết nội dung của một 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à trang web công khai). Các mục nhập sẽ chỉ được 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 mỗi địa chỉ email trong bảng điều khiển "Người có quyền truy cập" trên 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 hiển thị, mặc dù họ có quyền truy cập ngầm định vào một trang web.

Vai trò

Phần tử vai trò thể hiện cấp truy cập mà một thực thể có thể có. Phần tử gAcl:role có thể có bốn giá trị:

  • người đọc – người xem (tương đương với quyền chỉ có thể đọc).
  • tác giả – một cộng tác viên (tương đương với quyền đọc/ghi).
  • chủ sở hữu — thường là quản trị viên trang web (tương đương với quyền đọc/ghi).

Kính ngắm

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:

  • user — giá trị địa chỉ email, ví dụ: "user@gmail.com".
  • group — địa chỉ email của Google Group, ví dụ: "group@domain.com".
  • domain — tên miền G Suite, ví dụ như "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) của trang web đó. (Không dù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 "mặc định" 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 được đặt thành quyền truy cập "chủ sở hữu", chúng chỉ có thể là người đọc hoặc người ghi.

Giới thiệu về phạm vi "mời".

API 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 ACL mà chưa có tài khoản Google. API sẽ trả về một URL có mã thông báo được nhúng. Bạn phải cung cấp mã thông báo này 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 về địa chỉ email mà họ muốn sử dụng. Miễn là người dùng nhấp vào URL của lời mời có mã thông báo được nhúng, họ có thể đăng ký quyền 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 mời một người dùng hoặc một nhóm người dùng.

Lưu ý: Phạm vi "lời mời" 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 các 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ệuNội dung mô 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 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 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 của các mục nhập 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ẻ 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 phát yêu cầu POST tới nguồn cấp dữ liệu ACL của trang web.

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

Ví dụ sau đây 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 đượ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 phạm vi "mời"

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 bạn muốn mời. Sau khi nhấp vào URL, người dùng có thể truy cập vào trang web bằng cách đăng nhập bằng tài khoản hiện có hoặc tạo tài khoản mới.

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

<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 trên một nhóm Google hoặc miền G Suite. Giá trị scope cần thiết được liệt kê dưới đây.

Đang chia sẻ với địa chỉ email của 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"/>

Chúng tôi chỉ hỗ trợ chia sẻ ở cấp miền 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 phả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 các 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à cấp một yêu cầu HTTP PUT cho đường liên kết edit của mục nhập, đơn giản là phần tử <link>, trong đó thuộc tính "rel" được đặt thành "chỉnh sửa". Trong ví dụ trước, 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 xoá quyền chia sẻ

Để xoá quyền cho người dùng này, hãy gửi yêu cầu DELETE đến chính đường liên kết edit đã được 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 một nguồn cấp dữ liệu hoặc mục nhập mà bạn đã truy xuất trước đó, bạn có thể cải thiện tính hiệu quả bằng cách yêu cầu máy chủ chỉ gửi danh sách hoặc mục nhập nếu danh sách hoặc mục nhập đó đã thay đổi kể từ lần gần nhất 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 tiêu đề HTTP If-None-Match. Trong tiêu đề, hãy chỉ định ETag của danh sách hoặc mục nhập. Bạn có thể tìm thấy ETag này trong thuộc tính gd:etag của phần tử <feed> hoặc phần tử <entry>.

Một 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ục mà bạn yêu cầu có cùng ETag với ETag mà bạn đã chỉ định hay không. Nếu ETag khớp, thì mục đó sẽ không thay đổi và máy chủ sẽ trả về mã trạng thái HTTP 304 Not Modified hoặc mã trạng thái HTTP 412 Precodition Failed. Cả hai mã trạng thái đó cho biết mục bạn đã truy xuất đã được cập nhật.

Nếu ETag không khớp, thì mục này đã được sửa đổi kể từ lần cuối cùng bạn yêu cầu và máy chủ sẽ trả về mục.

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

Xử lý hàng loạt

Yêu cầu theo lô cho phép ứng dụng khách thực thi 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á sự thành công hay thất bại của từng hoạt động. Để biết thêm thông tin chi tiết về việc xử lý hàng loạt trong Google Data API, hãy xem bài viết Xử lý hàng loạt bằng API dữ liệu của Google

Mỗi tác vụ trong nguồn cấp dữ liệu hàng loạt đều có một phần tử <id>, ngoại trừ các thao tác chèn. Phần tử này giống với URL yêu cầu mà bạn thường sử 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 một nội dung chỉnh sửa, hãy đặt <id> thành đường liên kết edit cho mục nhập đang được đề cập. Giá trị này được dùng để xác định mục tiêu. Các mục nhập mới không có phần tử <id> 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 <batch:id>. Giá trị này sẽ đượ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.

Để gửi 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 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 thao tác:

 
<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