Google Sites API klasik memungkinkan aplikasi Anda mengakses, memublikasikan, dan mengubah konten dalam Google Site. Selain itu, aplikasi Anda dapat meminta daftar aktivitas terbaru, mengambil revisi histori, serta mengupload/mendownload lampiran dan file.
Audiens
Dokumen ini mengasumsikan bahwa Anda memahami ide umum di balik protokol Google Data API.
Dokumen ini ditujukan untuk pemrogram yang ingin menulis aplikasi klien yang dapat berinteraksi dengan Google Sites. Panduan ini menyediakan serangkaian contoh interaksi API data dasar menggunakan XML/HTTP mentah, dengan penjelasan. Setelah membaca dokumen ini, Anda dapat mempelajari lebih lanjut cara berinteraksi dengan API menggunakan library klien kami dengan membaca contoh bahasa tertentu yang ditemukan di panduan lain di navbar sebelah kiri.
Untuk referensi tentang materi dalam panduan ini, lihat panduan referensi.
Mengotorisasi permintaan
Saat aplikasi Anda meminta data pengguna non-publik, aplikasi harus menyertakan token otorisasi. Token ini juga mengidentifikasi aplikasi Anda ke Google.
Tentang protokol otorisasi
Aplikasi Anda harus menggunakan OAuth 2.0 untuk mengizinkan permintaan. Tidak ada protokol otorisasi lain yang didukung. Jika aplikasi Anda menggunakan Login dengan Google, beberapa aspek otorisasi akan ditangani untuk Anda.
Mengizinkan permintaan dengan OAuth 2.0
Permintaan ke Google Sites Data API untuk data pengguna non-publik harus diizinkan oleh pengguna yang diautentikasi.
Detail proses otorisasi, atau "alur", untuk OAuth 2.0 bervariasi bergantung pada jenis aplikasi yang Anda tulis. Proses umum berikut berlaku untuk semua jenis aplikasi:
- Saat membuat aplikasi, Anda mendaftarkannya menggunakan Konsol Google API. Selanjutnya, Google menyediakan informasi yang akan Anda perlukan nanti, seperti ID klien dan rahasia klien.
- Aktifkan Google Sites Data API di Konsol API Google. (Jika API tidak tercantum di Konsol API, lewati langkah ini.)
- Saat memerlukan akses ke data pengguna, aplikasi Anda akan meminta cakupan akses tertentu kepada Google.
- Google menampilkan layar izin kepada pengguna, yang meminta mereka mengizinkan aplikasi Anda untuk meminta beberapa data.
- Jika pengguna menyetujui, Google akan memberikan token akses berumur singkat ke aplikasi Anda.
- Aplikasi Anda meminta data pengguna, dengan menambahkan token akses ke permintaan.
- Jika Google menentukan bahwa permintaan Anda dan token tersebut valid, data yang diminta akan ditampilkan.
Beberapa alur mencakup langkah tambahan, seperti penggunaan token refresh untuk memperoleh token akses baru. Informasi selengkapnya tentang alur untuk berbagai jenis aplikasi dapat dilihat di dokumentasi OAuth 2.0 Google.
Berikut adalah informasi cakupan OAuth 2.0 untuk Google Sites Data API:
https://sites.google.com/feeds/
Untuk meminta akses menggunakan OAuth 2.0, aplikasi Anda memerlukan informasi cakupan, serta informasi yang disediakan oleh Google saat Anda mendaftarkan aplikasi (seperti ID klien dan rahasia klien).
Menentukan versi
Setiap permintaan yang Anda gunakan ke Google Sites Data API harus menetapkan versi 1.4. Untuk menentukan nomor versi, gunakan header HTTP GData-Version
:
GData-Version: 1.4
Atau, jika tidak dapat menetapkan header HTTP, Anda dapat menentukan v=1.4
sebagai parameter kueri di URL. Namun, Anda sebaiknya menggunakan header HTTP.
Catatan: Library klien menyediakan header versi yang sesuai secara otomatis, jadi jangan gunakan parameter kueri v=1.4
saat Anda menggunakan library klien.
Feed Situs
Feed situs dapat digunakan untuk mencantumkan Google Sites yang dimiliki pengguna atau memiliki izin lihat dan juga mengubah judul situs yang ada. Untuk domain G Suite, domain tersebut juga dapat digunakan untuk membuat atau menyalin seluruh situs.
Situs listingan
Untuk membuat daftar situs yang dapat diakses pengguna, kirim permintaan GET
yang diautentikasi ke URL berikut:
https://sites.google.com/feeds/site/domainName
Parameter feed | Deskripsi |
---|---|
domainName | 'site ' atau domain dari domain yang dihosting G Suite (misalnya, example.com ). |
Responsnya akan berisi feed dengan daftar situs:
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/"CkUAQH4_eil7I2A9WxNaFk4.""> <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/"DkQGQHczfA9WxNaFk4.""> <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>
Situs dicantumkan dalam urutan abjad.
Membuat situs baru
Catatan: Fitur ini hanya tersedia untuk domain G Suite.
Situs baru dapat disediakan dengan membuat POST
HTTP ke feed situs, misalnya:
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>
Permintaan di atas akan membuat situs Google baru dengan tema 'slate' di domain G Suite example.com
.
URL situs adalah http://sites.google.com/a/example.com/source-site/.
Jika situs berhasil dibuat, server akan merespons dengan 201 Created
.
Entri respons akan berisi elemen yang ditambahkan oleh server, seperti link ke situs, link ke feed ACL situs, nama situs, judul, dan ringkasan.
<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/"DEECR38l7I2A9WxNaF0Q.""> <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>
Menyalin situs
Catatan: Fitur ini hanya tersedia untuk domain G Suite.
Situs yang ada dapat diduplikasi dengan cara yang sama seperti membuat situs baru. Namun, dalam entri Atom permintaan POST
, sertakan <link>
dengan rel='source'
yang mengarah ke feed situs situs untuk disalin. Situs apa pun yang telah disalin akan memiliki link ini. Berikut adalah contoh untuk menduplikasi situs:
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>
Permintaan di atas akan menyalin situs tersebut di http://sites.google.com/a/example.com/source-site/.
Poin penting:
- Hanya situs dan template situs milik pengguna terautentikasi yang dapat disalin.
- Template situs juga dapat disalin. Situs merupakan template jika setelan "Publikasikan situs ini sebagai template" dicentang di halaman setelan Google Sites.
- Anda dapat menyalin situs dari domain lain, menunggu keputusan Anda terdaftar sebagai pemilik di situs sumber.
Memperbarui metadata situs
Untuk memperbarui judul atau ringkasan situs, kirim PUT
HTTP ke link edit
entri situs.
Misalnya, contoh berikut akan memperbarui judul situs sebelumnya menjadi New Test Site2
dan
deskripsinya menjadi 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/"DEECR38l7I2A9WxNaF0Q.""> <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>
Menambahkan Kategori
Catatan: Fitur ini hanya tersedia untuk domain G Suite.
G Suite untuk situs Domain Anda mencakup metadata yang berguna untuk mengategorikan situs dalam domain Anda. Untuk menambahkan atau memperbarui metadata meta kategori, kirimkan PUT
HTTP ke link edit
entri situs Anda yang menyertakan tag category
. Lihat baris tebal dalam contoh berikut:
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/"DEECR38l7I2A9WxNaF0Q.""> <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>
Contoh ini mengedit situs yang ada dan menambahkan kategori "Situs Tim".
Anda juga dapat menambahkan beberapa kategori dengan menambahkan tag <category>
tambahan. Lihat baris tebal dalam contoh berikut:
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/"DEECR38l7I2A9WxNaF0Q.""> <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>
Contoh ini menambahkan dua kategori: "Situs Tim" dan "Departemen Hukum"
Pemetaan alamat web
Pemetaan alamat web memungkinkan pengguna Sites memetakan domainnya sendiri ke sebuah Google Site. Misalnya, http://www.mydomainsite.com
dapat digunakan sebagai pengganti http://sites.google.com/a/domain.com/mysite
. Bergantung pada tempat situs dihosting, Anda dapat mengubah pemetaan alamat web situs secara manual. Lihat artikel pusat bantuan kami untuk mengetahui informasi selengkapnya.
Mengambil pemetaan alamat web situs
Untuk menampilkan pemetaan alamat web untuk situs, ambil entri/feed situs dengan parameter 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/"DkQGQHczfA9WxNaFk4.""> <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>
Pemetaan yang ada akan ditampilkan sebagai link
dengan rel='webAddressMapping'. Misalnya, pada contoh di atas, ada tiga webAddressMapping
yang mengarah ke situs http://sites.google.com/site/myOtherTestSite
.
Mengubah pemetaan alamat web
Catatan: Semua operasi GET/POST/PUT harus menentukan parameter with-mappings=true
saat menangani
pemetaan alamat web. Jika parameter tidak ada, webAddressMapping
tidak akan ditampilkan dalam entri situs (GET) atau dipertimbangkan
saat mengupdate/menghapus pemetaan (PUT) dari entri.
Untuk menambahkan, memperbarui, atau menghapus pemetaan, cukup tentukan, ubah, atau hapus link tersebut saat membuat situs baru atau
memperbarui metadata situs. Parameter with-mappings=true
harus disertakan di URI feed situs.
Catatan: untuk memperbarui pemetaan alamat, Anda harus menjadi admin situs, atau admin domain untuk situs yang dihosting G Suite.
Misalnya, permintaan di bawah ini memperbarui pemetaan http://www.mysitemapping.com
menjadi http://www.my-new-sitemapping.com
,
dan menghapus http://www.mysitemapping2.com
dengan membiarkan link tidak masuk:
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/"DkQGQHczfA9WxNaFk4.""> <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>
Catatan, Pemetaan alamat web juga dapat ditentukan pada saat membuat/menyalin situs.
Feed Aktivitas
Anda dapat mengambil aktivitas terbaru (perubahan) Situs dengan mengambil feed aktivitas. Setiap entri dalam feed aktivitas berisi informasi tentang perubahan yang dibuat pada Situs.
Untuk membuat kueri feed aktivitas, kirim GET
HTTP ke URL feed aktivitas:
https://sites.google.com/feeds/activity/domainName/siteName
Parameter feed | Deskripsi |
---|---|
domainName | 'site ' atau domain dari domain yang dihosting G Suite (misalnya, example.com ). |
siteName | Nama ruang web situs Anda; ditemukan di URL Situs (misalnya, myCoolSite ). |
Contoh permintaan dan respons:
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/"CU4GQ3szfSl7ImA9WxNRFUg.""> <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/"CU8DQn45fyl7ImA9WxNRFUg.""> <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/"CU8AR3s4cSl7ImA9WxNRFUg.""> <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>
Catatan: Untuk mengakses feed ini, Anda harus merupakan kolaborator atau pemilik Situs.
Klien Anda harus mengirimkan header Authorization
yang benar dan merujuk token yang diperoleh pada Permintaan otorisasi.
Feed Revisi
Untuk mengambil histori revisi bagi entri konten apa pun, kirim GET
HTTP ke link revisi entri:
https://sites.google.com/feeds/revision/domainName/siteName/CONTENT_ENTRY_ID
Parameter feed | Deskripsi |
---|---|
domainName | 'site ' atau domain dari domain yang dihosting G Suite (misalnya, example.com ). |
siteName | Nama ruang web situs Anda; ditemukan di URL Situs (misalnya, myCoolSite ). |
Untuk menemukan link revisi untuk halaman/komentar/lampiran/daftar item tertentu, ambil terlebih dahulu entri dari
feed konten menggunakan CONTENT_entri_ID-nya. Entri yang diambil akan berisi <atom:link>
ke feed revisi.
Contoh:
<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"/>
Contoh permintaan dan respons:
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/"CU4GQmA9WxNRFUg.""> <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&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/"CU8DQ388eSl7ImA9WxNRFUg.""> <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&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>
Catatan: Untuk mengakses feed ini, Anda harus merupakan kolaborator atau pemilik Situs.
Klien Anda harus mengirimkan header Authorization
yang benar dan merujuk token yang diperoleh pada Permintaan otorisasi.
Feed Konten
Mengambil konten
Feed konten mencantumkan konten situs saat ini. Kirim permintaan GET
yang diautentikasi ke URL berikut:
https://sites.google.com/feeds/content/domainName/siteName
Parameter feed | Deskripsi |
---|---|
domainName | 'site ' atau domain dari domain yang dihosting G Suite (misalnya, example.com ). |
siteName | Nama ruang web situs Anda; ditemukan di URL Situs (misalnya, myCoolSite ). |
Hasilnya adalah feed yang mencantumkan halaman pertama entri konten di Situs. Setiap entri dalam feed akan mewakili jenis entri konten yang berbeda, seperti webpage
, filecabinet
, attachment
, comment
, dll. Elemen <category scheme="http://schemas.google.com/g/2005#kind">
menentukan jenis entri. Lihat panduan referensi
untuk daftar nilai kind
dukungan.
Catatan: Feed ini mungkin memerlukan atau tidak memerlukan autentikasi; bergantung pada izin berbagi Situs.
Jika Situs non-publik, klien Anda harus mengirim header Authorization
yang benar (seperti yang terlihat pada contoh di atas)
dan merujuk token yang diperoleh di Permintaan otorisasi.
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/"Ck8GQXk7fil7ImA9WxNSFk0.""> <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/"CkMBQH08fCl7ImA9WxNSFk0.""> <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/"AkYHQ3ozcCl7ImA9WxJaE08.""> <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>
Catatan: Ini hanya beberapa hasil pertama. Untuk menelusuri seluruh feed konten, ikuti link 'berikutnya' pada feed:
<link rel="next" type="application/atom+xml" href="https://sites.google.com/feeds/content/domainName/siteName/?start-index=2"/>
Untuk penjelasan tentang elemen umum ke Atom, lihat referensi Google Data Protocol.
Elemen yang memiliki proses tertentu ke Sites API klasik dijelaskan di bawah. Entri jenis tertentu akan memiliki properti tambahan (tidak tercantum di bawah), sementara yang lain tidak. Misalnya, entri listitem
mungkin memiliki elemen <gs:field>
, sedangkan entri webpage
tidak.
Elemen | Deskripsi |
---|---|
<content ...> | Teks bagian dalam adalah isi HTML halaman. Untuk beberapa entri (misalnya lampiran), elemen ini akan berisi atribut src yang mengarah ke file. |
<link rel="alternate" ...> | Link ke halaman atau item di Google Sites. |
<link rel="http://schemas.google.com/sites/2008#revision" ...> | Atribut href mengarah ke feed revisi entri. |
<link rel="http://schemas.google.com/sites/2008#parent" ...> | Atribut href mengarah ke entri induk entri. |
<link rel="http://schemas.google.com/sites/2008#template" ...> | Atribut href mengarah ke halaman template entri. |
<category scheme="http://schemas.google.com/g/2005#kind" ...> | label adalah jenis entri. |
<category term="http://schemas.google.com/g/2005#template" ...> | label=template yang menandakan entri adalah template. |
<gd:feedLink> | Atribut href mengarah ke turunan dari induk entri. |
<sites:pageName> | Nama ruang web halaman; terkait dengan nama di URL halaman. |
<sites:revision> | Nomor revisi saat ini. |
Contoh kueri feed konten
Anda dapat menelusuri feed konten menggunakan beberapa parameter kueri Google Data API standar dan yang khusus untuk Sites API klasik. Untuk mengetahui informasi yang lebih mendetail dan daftar lengkap parameter yang didukung, lihat Panduan Referensi.
Mengambil jenis entri tertentu
Untuk mengambil jenis entri tertentu saja, gunakan parameter kind
. Contoh ini hanya menampilkan webpage
entri:
GET /feeds/content/domainName/siteName?kind=webpage
Untuk menampilkan lebih dari satu jenis entri, pisahkan setiap kind
dengan ','. Contoh ini menampilkan entri filecabinet
dan
listpage
:
GET /feeds/content/domainName/siteName?kind=filecabinet,listpage
Atau, Anda dapat menggunakan format standar untuk kueri /-/category
Data Google, bukan parameter kind
:
GET /feeds/content/domainName/siteName/-/filecabinet|listpage
Mengambil template halaman
Contoh ini hanya menampilkan template
halaman:
GET /feeds/content/domainName/siteName/-/template
Untuk menampilkan semua jenis entri dan menyertakan halaman template
, gunakan:
GET /feeds/content/domainName/siteName/-/template|-template
Mengambil halaman menurut jalur
Jika mengetahui jalur relatif halaman dalam Situs Google, Anda dapat menggunakan parameter path
untuk mengambil halaman tertentu.
Contoh ini akan menampilkan halaman yang terletak di
http://sites.google.com/site/siteName/path/to/the/page
:
GET /feeds/content/domainName/siteName?path=/path/to/the/page
Mengambil semua entri di halaman induk
Jika Anda mengetahui ID entri halaman, Anda dapat menggunakan parameter parent
untuk mengambil semua entri turunannya (jika ada):
GET /feeds/content/domainName/siteName?parent=CONTENT_ENTRY_ID
Termasuk draf atau entri yang dihapus
Untuk menyertakan entri draf atau entri yang dihapus, gunakan parameter include-drafts
atau include-deleted
.
Contoh ini mencakup entri draf di feed konten:
GET /feeds/content/domainName/siteName?include-drafts=true
Penelusuran teks lengkap
Untuk menelusuri seluruh konten situs, gunakan parameter q
untuk melakukan penelusuran teks lengkap:
GET /feeds/content/domainName/siteName?q=Text%20I%20am%20looking%20for
Membuat Konten
Konten baru (halaman web, halaman daftar, halaman lemari file, halaman pengumuman, dll.) dapat dibuat dengan mengirimkan POST
HTTP ke feed konten:
https://sites.google.com/feeds/content/domainName/siteName
Untuk daftar jenis entri yang didukung, lihat parameter kind
di Panduan Referensi.
Membuat item / halaman baru
Contoh ini membuat webpage
baru di bagian atas Situs, termasuk beberapa XHTML untuk isi halaman,
dan menetapkan judul judul ke 'New WebPage Title':
POST /feeds/content/domainName/siteName HTTP/1.1 Host: sites.google.com GData-Version: 1.4 Authorization: <your authorization header here> Content-Length: 328 Content-Type: application/atom+xml <entry xmlns="http://www.w3.org/2005/Atom"> <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#webpage" label="webpage"/> <title>New Webpage Title</title> <content type="xhtml"> <div xmlns="http://www.w3.org/1999/xhtml">HTML body goes here</div> </content> </entry>
Jika berhasil, server akan merespons dengan 201 Created
dan salinan entri.
Membuat item/halaman di jalur URL kustom
Secara default, contoh sebelumnya akan dibuat pada URL
http://sites.google.com/domainName/siteName/new-webpage-title
dan
memiliki judul halaman 'Judul Halaman Baru'. Artinya, <atom:title>
dinormalkan menjadi new-webpage-title
untuk URL.
Untuk menyesuaikan jalur URL halaman, Anda dapat menetapkan elemen <sites:pageName>
.
Contoh ini membuat filecabinet
baru dengan judul halaman 'File Storage', tetapi membuat halaman dengan URL http://sites.google.com/domainName/siteName/files
dengan
menentukan elemen <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>
Server menggunakan aturan prioritas berikut untuk menamai jalur URL halaman:
<sites:pageName>
, jika ada. Harus memenuhia-z, A-Z, 0-9, -, _
.<atom:title>
, tidak boleh null jika pageName tidak ada. Normalisasi adalah untuk memangkas + menciutkan spasi kosong menjadi '-' dan menghapus karakter yang tidak cocok dengana-z, A-Z, 0-9, -, _
.
Misalnya, 'Custom_Page2' akan diterima oleh server.
Membuat subhalaman
Untuk membuat subhalaman (turunan) di halaman induk, sertakan <link rel="http://schemas.google.com/sites/2008#parent">
dalam
entri Atom baru Anda. Tetapkan atribut href
link ke link mandiri entri induk.
Contoh ini akan membuat announcement
baru dengan judul 'pengumuman', di bagian halaman pengumuman induk dengan ID
entri PARENT_ENTRY_ID
. Konten XHTML untuk isi halaman juga disertakan:
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>
Template halaman
Membuat template halaman
Proses pembuatan template halaman sama dengan membuat item/halaman baru dan
membuat subhalaman.Perbedaannya adalah setiap penambahan category
dengan istilah dan label yang ditetapkan ke 'http://schemas.google.com/g/2005#template'
dan 'template'.
Contoh ini membuat template webpage
baru.
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>
Membuat halaman dari template
Serupa dengan membuat template halaman, Anda dapat membuat instance halaman baru dari template dengan menyertakan <link>
dengan rel='http://schemas.google.com/sites/2008#template' yang mengarah ke link mandiri template halaman.
Contoh ini membuat halaman filecabinet
baru dari template halaman yang ada yang menentukan lemari file.
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>
Catatan: Meskipun template yang menentukan <category>
, Anda juga harus menyertakan template dalam entri. Perlu diketahui juga bahwa jika Anda menyertakan elemen <content>
, server akan menolaknya.
Mengupload file
Sama seperti di Google Sites, API memungkinkan Anda mengupload lampiran ke halaman lemari file dan halaman induk.
Untuk mengupload lampiran ke induk, kirim permintaan POST
HTTP ke URL feed konten:
https://sites.google.com/feeds/content/domainName/siteName
Isi POST
harus berupa permintaan multibagian MIME, untuk menggabungkan konten file dengan
<atom:entry>
yang berisi metadata lampiran. <atom:entry>
harus merujuk
pada link mandiri entri induk, untuk menentukan tempat lampiran akan dibuat.
Lihat Membuat subhalaman untuk informasi selengkapnya.
Mengupload lampiran
Berikut adalah contoh cara mengupload file PDF ke lemari file dengan ID PARENT_ENTRY_ID
. Lampiran akan dibuat
dengan judul 'File PDF' dan deskripsi (opsional), 'paket 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--
Jika upload berhasil, server akan merespons dengan 201 Created
dan salinan entri lampiran yang baru dibuat.
Mengupload lampiran ke folder
Untuk mengupload lampiran ke folder yang ada di filecabinet
, sertakan kategori dengan atribut 'term' yang disetel ke nama folder:
<category scheme="http://schemas.google.com/sites/2008#folder" term="FolderName">
Lampiran web
Lampiran web adalah jenis lampiran khusus. Pada dasarnya, link adalah link ke file lain di web yang dapat ditambahkan ke listingan lemari file Anda. Fitur ini sejalan dengan metode upload 'Tambahkan file menurut URL' di UI Google Sites.
Catatan: Lampiran web hanya dapat dibuat di lemari file. Gambar tidak dapat diupload ke jenis halaman lain.
Contoh ini membuat webattachment
pada lemari file yang direferensikan oleh ID FILECABINET_ENTRY_ID
.
Judul dan deskripsi (opsional) masing-masing ditetapkan ke 'GoogleLogo' dan 'nice colors'.
POST /feeds/content/domainName/siteName HTTP/1.1 Host: sites.google.com GData-Version: 1.4 Authorization: <your authorization header here> Content-Type: application/atom+xml Content-Length: 531 <entry xmlns="http://www.w3.org/2005/Atom"> <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#webattachment" label="webattachment"/> <link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml" href="https://sites.google.com/feeds/content/domainName/siteName/FILECABINET_ENTRY_ID"/> <title>GoogleLogo</title> <summary>nice colors</summary> <content type="image/gif" src="http://www.google.com/images/logo.gif"></content> </entry>
POST
akan membuat link di lemari file pengguna yang mengarah ke gambar di 'http://www.google.com/images/logo.gif'.
Memperbarui Konten
Metadata (judul, pageName, dll.) dan konten halaman dari setiap halaman dapat diedit dengan satu permintaan PUT
ke link edit
.
Isi permintaan harus berisi entri Atom yang mendeskripsikan halaman yang diperbarui. Pengecualian untuk aturan ini adalah entri lampiran, dengan entri yang hanya dapat digunakan untuk memperbarui metadata lampiran.
Untuk mengubah konten file terlampir, cukup sertakan data mentah sebagai isi permintaan PUT
ke link edit-media
lampiran. Anda juga dapat memperbarui metadata dan konten file terlampir sekaligus dengan menggunakan permintaan multibagian MIME.
Untuk menegaskan bahwa pembaruan Anda tidak menimpa perubahan klien lain, sertakan nilai ETag entri asli. Anda dapat melakukannya dengan memberikan nilai ETag di header If-Match
HTTP, atau dengan menyertakan atribut gd:etag
entri asli dalam entri yang diperbarui. Untuk menentukan nilai ETag entri asli, periksa atribut gd:etag
elemen <entry>
.
Untuk entri media, ETag media mungkin tersedia di atribut gd:etag
link edit-media
.
Jika Anda ingin memperbarui entri terlepas dari apakah orang lain telah memperbaruinya sejak Anda mengambilnya, gunakan
If-Match: *
dan jangan sertakan ETag. Untuk mengetahui informasi selengkapnya tentang ETag, lihat panduan referensi Google Data API.
Memperbarui metadata atau konten html item
Untuk mengupdate metadata atau konten HTML entri, kirim PUT
HTTP ke link edit
entri.
Berikut adalah contoh cara memperbarui entri listpage
(ditunjukkan dengan ID ENTRY_ID
-nya) dengan perubahan berikut:
- Judul diubah menjadi 'Konten yang Diperbarui'
- Konten HTML terbaru
- Judul kolom pertama dari daftar diperbarui menjadi 'Pemilik'
- Jalur URL halaman diubah oleh elemen
<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/"CEEBRn0ymA9WxJWEUw.""> <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>
Catatan: Entri (seperti yang ditampilkan oleh server) akan berisi lebih banyak elemen daripada contoh di atas.
Mengganti konten lampiran
Berikut adalah contoh penggantian konten lampiran, tetapi jangan mengubah metadatanya. Karena permintaan berisi konten baru,
link edit-media
entri lampiran akan digunakan.
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 ...
Memperbarui metadata lampiran + konten
Berikut adalah contoh cara memperbarui metadata lampiran dan kontennya secara bersamaan. Nama lampiran akan diperbarui menjadi 'Judul Baru' dan isinya akan diganti dengan konten file .zip. Karena permintaan berisi konten file baru, link
edit-media
entri lampiran akan digunakan.
Perlu diperhatikan bahwa menyertakan ETag untuk metadata juga akan memberikan If-Match
implisit untuk konten media, karena update pada
konten media akan menyebabkan ETag metadata berubah.
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
Menghapus Konten
Untuk menghapus item dari Situs Google, ambil entri terlebih dahulu, lalu kirim permintaan DELETE
ke URL edit
entri. URL ini sama dengan yang digunakan saat memperbarui metadata item atau konten html.
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>
Jika entri berhasil dihapus, server akan merespons dengan 200 OK
HTTP.
Jika ingin memastikan bahwa Anda tidak menghapus entri yang telah diubah oleh klien lain sejak mengambilnya, sertakan header If-Match
HTTP yang berisi nilai ETag entri asli. Anda dapat menentukan nilai ETag entri asli dengan memeriksa atribut gd:etag
elemen <entry>
.
Jika Anda ingin menghapus entri tersebut terlepas dari apakah orang lain telah memperbaruinya sejak Anda mengambilnya, gunakan
If-Match: *
dan jangan sertakan ETag. (Dalam hal ini, Anda tidak perlu mengambil entri sebelum menghapusnya.)
Untuk informasi selengkapnya tentang ETag, lihat panduan referensi Google Data API.
Mendownload Lampiran
Setelah memiliki entri lampiran, Anda dapat mendownload file tersebut dengan mengirim GET
HTTP terautentikasi ke link src <content>
entri. Contoh link konten PDF:
<content type="application/pdf" src="http://502377765-a-google-com-s-sites.googlegroups.com/feeds/media/content/domainName/siteName/678942036"/>
Feed ACL
Ringkasan Izin Berbagi (ACL)
Setiap entri ACL di feed ACL mewakili peran akses dari entitas tertentu, baik pengguna, grup pengguna, domain, atau akses default (yang merupakan situs publik). Entri hanya akan ditampilkan untuk entitas dengan akses eksplisit - satu entri akan ditampilkan untuk setiap alamat email di panel "Orang dengan Akses" di layar berbagi UI Google Sites. Dengan demikian, admin domain tidak akan ditampilkan, meskipun mereka memiliki akses implisit ke situs.
Peran
Elemen peran mewakili tingkat akses yang dapat dimiliki entitas. Ada empat kemungkinan nilai elemen gAcl:role
:
- reader — pelihat (setara dengan akses hanya baca).
- author — kolaborator (setara dengan akses baca/tulis).
- owner — biasanya admin situs (setara dengan akses baca/tulis).
Cakupan
Elemen cakupan mewakili entitas yang memiliki tingkat akses ini. Ada lima kemungkinan jenis elemen gAcl:scope
:
- pengguna — nilai alamat email, misalnya "pengguna@gmail.com".
- group — alamat email Google Grup, misalnya "grup@domain.com".
- domain — nama domain G Suite, mis. "domain.com".
- undang — pengguna yang telah diundang ke situs, tetapi belum ditambahkan ke ACL untuk situs. (Tidak tersedia jika gdata 1.3 atau yang lebih rendah ditentukan.)
- default — Hanya ada satu kemungkinan jenis cakupan "default", yang tidak memiliki nilai
(misalnya
<gAcl:scope type="default">
). Cakupan khusus ini mengontrol akses yang dimiliki oleh setiap pengguna secara default di situs publik.
Catatan: Nilai gAcl:role
tidak dapat ditetapkan ke akses "pemilik" di domain. Domain hanya dapat menjadi pembaca atau penulis.
Tentang cakupan "undang".
API menampilkan cakupan undangan saat Anda menambahkan satu atau beberapa pengguna ke ACL yang belum memiliki akun Google. API menampilkan URL dengan token tersemat yang harus Anda berikan kepada pengguna yang diundang agar mereka dapat menerima undangan.
Metode undangan ini memungkinkan Anda mengundang pengguna non-Google tanpa mengetahui alamat email yang ingin digunakan sebelumnya. Selama pengguna mengklik URL undangan dengan token tersemat, mereka dapat mendaftar untuk mendapatkan akses menggunakan alamat email apa pun yang mereka inginkan. Selain itu, beberapa pengguna berpotensi menggunakan URL ini untuk menerima undangan, sehingga dapat berguna jika mengundang satu pengguna atau sekelompok pengguna.
Catatan: Cakupan "undangan" hanya tersedia di gdata versi 1.4 dan yang lebih baru. Ini tidak akan berhasil jika Anda secara eksplisit menentukan versi 1.3 atau yang lebih lama.
Mengambil feed ACL
Feed ACL dapat digunakan untuk mengontrol izin berbagi situs dan dapat diakses melalui URI berikut:
https://sites.google.com/feeds/acl/site/domainName/siteName
Parameter feed | Deskripsi |
---|---|
domainName | 'site ' atau domain dari domain yang dihosting G Suite (misalnya, example.com ). |
siteName | Nama ruang web situs Anda; ditemukan di URL Situs (misalnya, myCoolSite ). |
Perlu diperhatikan bahwa setiap entri dalam feed situs berisi link ke feed ini:
<link rel="http://schemas.google.com/acl/2007#accessControlList" type="application/atom+xml" href="https://sites.google.com/feeds/acl/site/domainName/siteName"/>
Untuk mengambil izin berbagi situs, kirim dan HTTP GET
ke URI feed ACL:
GET /feeds/acl/site/domainName/siteName HTTP/1.1 Host: sites.google.com GData-Version: 1.4 Authorization: <your authorization header here>
Server akan merespons dengan 200 OK
dan feed entri 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>
Berbagi situs
Feed ACL menerima permintaan GET
, POST
, dan PUT
. Untuk menyisipkan peran baru ke feed ACL, cukup kirimkan permintaan POST
ke feed ACL situs.
Catatan: ACL berbagi tertentu mungkin hanya mungkin jika domain dikonfigurasi untuk mengizinkan izin tersebut (misalnya jika berbagi di luar domain untuk domain G Suite diaktifkan, dsb).
Contoh ini menambahkan kolaborator (penulis) baru ke situs:
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
dan entri baru akan ditampilkan jika penyisipan berhasil:
<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>
Mengundang pengguna melalui cakupan "undang"
Jika Anda menambahkan pengguna yang tidak memiliki Akun Google, API akan menampilkan URL yang harus Anda berikan kepada pengguna yang ingin diundang. Setelah mengklik URL, mereka akan mendapatkan akses ke situs dengan login menggunakan akun yang sudah ada, atau membuat akun baru.
Undangan yang berhasil akan menampilkan 201 Created
dan entri baru yang menyertakan URL yang harus Anda teruskan kepada pengguna:
<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>
Berbagi tingkat Grup dan Domain
Serupa dengan berbagi situs dengan satu pengguna, Anda dapat berbagi situs di seluruh grup Google atau domain G Suite. Nilai scope
yang diperlukan tercantum di bawah.
Berbagi ke alamat email grup:
<gAcl:scope type="group" value="group@example.com"/>
Berbagi ke seluruh domain:
<gAcl:scope type="domain" value="example.com"/>
Berbagi di tingkat domain hanya didukung untuk domain G Suite, dan hanya untuk domain tempat situs dihosting. Misalnya, http://sites.google.com/a/domain1.com/siteA hanya dapat membagikan seluruh Situs ke domain1.com, bukan domain2.com. Situs yang tidak dihosting di domain G Suite (misalnya, http://sites.google.com/site/siteB) tidak dapat mengundang domain.
Mengubah izin berbagi
Untuk memperbarui entri ACL, ubah entri seperlunya, dan keluarkan permintaan PUT
HTTP ke link edit
entri, yang merupakan elemen <link>
, yang atribut 'rel'-nya ditetapkan ke 'edit'. Untuk contoh sebelumnya, link tersebut adalah:
<link rel='edit' type='application/atom+xml' href='https://sites.google.com/feeds/acl/site/domainName/siteName/user%3Anew_writer%40example.com'/>
Cuplikan di bawah mengubah peran new_writer@gmail.com
menjadi 'reader':
PUT /feeds/acl/site/domainName/siteName/user%3Anew_writer%40example.com HTTP/1.1 Host: sites.google.com GData-Version: 1.4 Authorization: <your authorization header here> <entry xmlns="http://www.w3.org/2005/Atom" xmlns:gAcl='http://schemas.google.com/acl/2007'> <category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/acl/2007#accessRule'/> <gAcl:role value='reader'/> <gAcl:scope type='user' value='new_writer@gmail.com'/> </entry>
Menghapus izin berbagi
Untuk menghapus izin pengguna ini, buat permintaan DELETE
ke link edit
yang sama dengan yang digunakan untuk permintaan 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>
Server akan merespons dengan 200 OK
.
Topik Khusus
Mengambil feed atau entri lagi
Jika Anda ingin mengambil feed atau entri yang telah diambil sebelumnya, Anda dapat meningkatkan efisiensi dengan memberi tahu server untuk mengirim daftar atau entri hanya jika server telah berubah sejak terakhir kali Anda mengambilnya.
Untuk melakukan pengambilan bersyarat ini, kirim permintaan GET
HTTP yang menyertakan header If-None-Match
HTTP. Di header, tentukan ETag daftar atau entri, yang dapat Anda temukan di
atribut gd:etag
elemen <feed>
atau <entry>
.
Contoh penggunaan feed situs:
GET /feeds/site/domainName/myOtherTestSite/ GData-Version: 1.4 If-None-Match: W/"Ck8GQXk7fil7ImA9WxNSFk0."
Ketika menerima permintaan ini, server akan memeriksa apakah item yang Anda minta memiliki ETag yang sama dengan ETag yang Anda tentukan. Jika ETag cocok, maka item tidak berubah, dan server menampilkan kode status Not Modified
HTTP 304 atau kode status HTTP 412 Precodition Failed
. Kedua kode status tersebut menunjukkan bahwa item yang telah Anda ambil adalah yang terbaru.
Jika ETag tidak cocok, maka item telah dimodifikasi sejak terakhir kali Anda memintanya, dan server mengembalikan item.
Untuk informasi selengkapnya tentang ETag, lihat panduan referensi Google Data API.
Batch Processing
Permintaan batch memberi klien kemampuan untuk menjalankan beberapa operasi dalam satu permintaan, bukan mengirim setiap operasi satu per satu.
Server akan menjalankan sebanyak mungkin perubahan yang diminta dan menampilkan informasi status yang dapat Anda gunakan untuk mengevaluasi keberhasilan atau kegagalan setiap operasi. Untuk detail selengkapnya tentang batch processing di Google Data API, lihat Batch Processing with Google Data API
Setiap operasi dalam feed batch memiliki elemen <id>, kecuali untuk operasi penyisipan.
Elemen ini sama seperti URL permintaan yang biasanya Anda gunakan saat mengupdate, menghapus, atau membuat kueri feed konten.
Misalnya, jika Anda memperbarui hasil edit, tetapkan <id> ke link edit
untuk entri yang dimaksud.
ID ini digunakan untuk mengidentifikasi entri target. Entri baru tidak memiliki elemen <id> karena belum dibuat. Sebagai gantinya, Anda dapat menentukan nilai string di <batch:id>, yang akan ditampilkan dalam respons server dan digunakan untuk mencari entri yang sesuai.
Untuk membuat permintaan batch, buat feed batch dan kirim POST
HTTP ke link batch feed:
<link rel="http://schemas.google.com/g/2005#batch" type="application/atom+xml" href="https://sites.google.com/feeds/content/site/siteName/batch"/>
Contoh di bawah menunjukkan cara membuat kueri, menyisipkan, memperbarui, dan menghapus entri halaman:
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=""YDgpeyI.""> <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=""YassseyI.""> <id>https://sites.google.com/feeds/content/site/siteName/ENTRY_ID3</id> <batch:operation type='delete'/> </entry> </feed>
Feed yang ditampilkan akan berisi satu entri hasil untuk setiap operasi:
<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=""YDgpsdfeyI."">
<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=""YDsseyI."">
<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=""YDkpeyI."">
<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>