מדריך לפרוטוקול

הגרסה הקלאסית של Google Sites API מאפשרת לאפליקציות שלכם לגשת לתוכן ב-Google Sites, לפרסם אותו ולשנות אותו. בנוסף, האפליקציה יכולה לבקש רשימה של פעילויות אחרונות, לאחזר את היסטוריית הגרסאות ולהעלות או להוריד קבצים וקבצים מצורפים.

קהל

הנחת המוצא במסמך הזה היא שאתם מבינים את הרעיונות הכלליים שמאחורי הפרוטוקול של Google Data APIs.

המסמך הזה מיועד למתכנתים שרוצים לכתוב אפליקציות לקוח שיכולות לקיים אינטראקציה עם Google Sites. הוא מספק סדרה של דוגמאות לאינטראקציות בסיסיות של Data API באמצעות XML/HTTP גולמי, עם הסברים. אחרי שתקראו את המסמך הזה, תוכלו לקרוא את הדוגמאות הספציפיות לשפה במדריכים האחרים בסרגל הניווט הימני כדי לקבל מידע נוסף על האינטראקציה עם ה-API באמצעות ספריות הלקוח שלנו.

לעיון בחומר שבמדריך הזה, ראו את מדריך העזר.

אישור בקשות

כשהאפליקציה מבקשת נתוני משתמשים לא ציבוריים, היא חייבת לכלול אסימון הרשאה. אסימון ההרשאה גם מזהה את האפליקציה שלכם ב-Google.

הסבר על פרוטוקולים של הרשאות

כדי לאשר בקשות, האפליקציה חייבת להשתמש בפרוטוקול OAuth 2.0. אין תמיכה בפרוטוקולים אחרים של הרשאות. אם האפליקציה משתמשת בכניסה באמצעות חשבון Google, היבטים מסוימים של ההרשאות מטופלים באופן אוטומטי.

הרשאת בקשות עם פרוטוקול OAuth 2.0

בקשות ל-Google Sites Data API לנתוני משתמשים לא ציבוריים חייבות להיות מאושרות על ידי משתמש מאומת.

הפרטים או ה"זרימה" של תהליך ההרשאה עם OAuth 2.0 עשויים להשתנות מעט, בהתאם לסוג האפליקציה שאתם מפתחים. התהליך הכללי הבא חל על כל סוגי האפליקציות:

  1. כשאתם מפתחים את האפליקציה, צריך לרשום אותה באמצעות Google API Console. לאחר הרישום, Google מספקת נתונים שיהיו דרושים לכם מאוחר יותר, כמו מזהה לקוח וסוד לקוח.
  2. מפעילים את Google Sites Data API ב-Google API Console. (אם Cloud Billing API לא מופיע ב-API Console, אפשר לדלג על השלב הזה).
  3. כשהאפליקציה צריכה גישה לנתונים של משתמשים, היא מעבירה ל-Google בקשת גישה בהיקף ספציפי.
  4. Google מציגה למשתמש מסך הסכמה ומבקשת לאשר לאפליקציה לשלוח בקשה לחלק מהנתונים שלו.
  5. אם המשתמש מסכים, האפליקציה מקבלת מ-Google אסימון גישה לטווח קצר.
  6. האפליקציה מבקשת את נתוני המשתמש ומצרפת לבקשה את אסימון הגישה.
  7. אם Google תקבע שהבקשה והאסימון תקפים, היא תחזיר את הנתונים המבוקשים.

חלק מתהליכי העבודה כוללים שלבים נוספים, כמו שימוש באסימוני רענון כדי לקבל אסימוני גישה חדשים. למידע מפורט על תהליכי העבודה לסוגים שונים של אפליקציות, ניתן לעיין בתיעוד של OAuth 2.0 של Google.

הפרטים לגבי היקפי OAuth 2.0 ב-Google Sites Data API:

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

כדי לבקש גישה באמצעות פרוטוקול OAuth 2.0, האפליקציה שלכם זקוקה למידע על ההיקף ולמידע ש-Google מספקת בזמן רישום האפליקציה (כמו מזהה לקוח וסוד לקוח).

חזרה למעלה

ציון גרסה

כל בקשה שאתם שולחים ל-Google Sites Data API צריכה לציין את גרסה 1.4. כדי לציין מספר גרסה, משתמשים בכותרת ה-HTTP ‏GData-Version:

GData-Version: 1.4

לחלופין, אם אתם לא יכולים להגדיר כותרות HTTP, אתם יכולים לציין את v=1.4 כפרמטר של שאילתה בכתובת ה-URL. אבל כשאפשר, עדיף להשתמש בכותרת ה-HTTP.

הערה: ספריות הלקוח מספקות כותרות גרסה מתאימות באופן אוטומטי, לכן אל תשתמשו בפרמטר השאילתה v=1.4 כשאתם משתמשים בספריית לקוח.

חזרה למעלה

פיד האתר

אפשר להשתמש בפיד האתר כדי להציג את האתרים ב-Google Sites שבבעלות המשתמש או שיש לו הרשאות צפייה בהם, וגם לשנות את השם של אתר קיים. בדומיינים של G Suite, אפשר להשתמש בו גם כדי ליצור או להעתיק אתר שלם.

אתרים לפרסום מודעות

כדי להציג את רשימת האתרים שלמשתמש יש גישה אליהם, שולחים בקשת GET מאומתת לכתובת ה-URL הבאה:

https://sites.google.com/feeds/site/domainName
פרמטר של פידתיאור
domainName"site" או הדומיין של הדומיין המתארח ב-G Suite (למשל example.com).

התשובה תכיל פיד עם רשימה של אתרים:

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

HTTP/1.1 200 OK

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

האתרים מופיעים בסדר אלפביתי.

יצירת אתרים חדשים

הערה: התכונה הזו זמינה רק בדומיינים של G Suite.

אפשר להקצות אתרים חדשים על ידי ביצוע בקשת HTTP POST לפיד האתר, לדוגמה:

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

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

הבקשה שלמעלה תיצור אתר בגרסה החדשה של Google Sites עם העיצוב 'צפחה' בדומיין G Suite‏ example.com. כתובת ה-URL של האתר תהיה http://sites.google.com/a/example.com/source-site/‎.

אם האתר נוצר בהצלחה, השרת ישיב עם 201 Created. הרשומה בתגובה תכיל רכיבים שהשרת הוסיף, כמו קישור לאתר, קישור לפיד ה-ACL של האתר, שם האתר, הכותרת והתקציר.

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

העתקת אתר

הערה: התכונה הזו זמינה רק לדומיינים של G Suite.

אפשר לשכפל אתר קיים באותו אופן שבו יוצרים אתר חדש ב-Google Sites. עם זאת, ברשומת Atom של הבקשה POST, צריך לכלול <link> עם rel='source' שמצביע על פיד האתר של האתר שרוצים להעתיק. הקישור הזה יופיע בכל אתר שהועתק. דוגמה לשכפול אתר:

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

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

הבקשה שלמעלה תעתיק את האתר בכתובת http://sites.google.com/a/example.com/source-site/.

נקודות חשובות:

  • אפשר להעתיק רק אתרים ותבניות אתרים שבבעלות המשתמש המאומת.
  • אפשר גם להעתיק תבנית של אתר. אתר נחשב לתבנית אם ההגדרה "פרסום האתר הזה כתבנית" מסומנת בדף ההגדרות של Google Sites.
  • אתם יכולים להעתיק אתר מדומיין אחר, בתנאי שאתם רשומים כבעלים באתר המקור.

עדכון המטא-נתונים של האתר

כדי לעדכן את הכותרת או הסיכום של אתר, שולחים בקשת HTTP PUT לקישור edit של רשומת האתר. לדוגמה, הקוד הבא יעדכן את הכותרת של האתר הקודם ל-New Test Site2 ואת התיאור שלו ל-Newer description.

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

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

הוספת קטגוריות

הערה: התכונה הזו זמינה רק לדומיינים של G Suite.

אתרים ב-G Suite for your Domain כוללים מטא-נתונים של קטגוריות, שמועילים לסיווג אתרים בדומיין שלכם. כדי להוסיף או לעדכן מטא-נתונים של קטגוריה, שולחים בקשת HTTP PUT לקישור edit של רשומת האתר שכוללת תג category. השורה המודגשת בדוגמה הבאה:

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

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

בדוגמה הזו עורכים אתר קיים ומוסיפים את הקטגוריה "אתר צוות".

אפשר גם להוסיף כמה קטגוריות באמצעות תגי <category> נוספים. השורות המודגשות בדוגמה הבאה:

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

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

בדוגמה הזו נוספות שתי קטגוריות: "אתר הצוות" ו "המחלקה המשפטית"

מיפוי כתובות אינטרנט

מיפוי כתובות אינטרנט מאפשר למשתמשי Google Sites למפות את הדומיינים שלהם לאתר ב-Google Sites. לדוגמה, אפשר להשתמש ב-http://www.mydomainsite.com במקום ב-http://sites.google.com/a/domain.com/mysite. בהתאם למקום שבו האתר מתארח, אתם יכולים לשנות באופן ידני את מיפויי כתובות האינטרנט של האתר. מידע נוסף זמין במאמר הזה במרכז העזרה.

אחזור מיפוי כתובות אינטרנט של אתר

כדי להחזיר את מיפויי כתובות האינטרנט של אתר, מאחזרים את הרשומה או הפיד של האתר עם הפרמטר with-mappings=true:

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

HTTP/1.1 200 OK

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

מיפויים קיימים יופיעו בתור link עם rel='webAddressMapping'. לדוגמה, בדוגמה שלמעלה יש שלושה webAddressMapping שמפנים לאתר http://sites.google.com/site/myOtherTestSite.

שינוי מיפוי כתובות אינטרנט

הערה: כל פעולות GET/POST/PUT צריכות לציין את הפרמטר with-mappings=true כשעובדים עם מיפוי כתובות אינטרנט. אם הפרמטר לא קיים, webAddressMapping לא יוחזרו ברשומות של האתר (GET) או יילקחו בחשבון כשמעדכנים או מסירים (PUT) מיפויים מרשומה.

כדי להוסיף, לעדכן או למחוק מיפוי, פשוט מציינים, משנים או מסירים קישור כזה כשיוצרים אתרים חדשים או כשמעדכנים את המטא-נתונים של אתר. הפרמטר with-mappings=true חייב להיכלל ב-URI של הפיד באתר. הערה: כדי לעדכן מיפויים של כתובות, צריך להיות אדמין של האתר, או אדמין של הדומיין במקרה של אתר שמתארח ב-G Suite.

לדוגמה, הבקשה הבאה מעדכנת את המיפוי של http://www.mysitemapping.com ל-http://www.my-new-sitemapping.com, ומסירה את http://www.mysitemapping2.com על ידי השארת הקישור מחוץ לרשומה:

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

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

הערה: אפשר גם לציין מיפוי כתובות אינטרנט כשיוצרים או מעתיקים אתר.

חזרה למעלה

פיד הפעילות

כדי לאחזר את הפעילות האחרונה (השינויים) באתר, אפשר לאחזר את פיד הפעילות. כל רשומה בפיד הפעילות מכילה מידע על שינוי שבוצע באתר.

כדי לשלוח שאילתה לפיד הפעילות, שולחים בקשת HTTP GET לכתובת ה-URL של פיד הפעילות:

https://sites.google.com/feeds/activity/domainName/siteName
פרמטר של פידתיאור
domainName"site" או הדומיין של הדומיין המתארח ב-G Suite (למשל example.com).
siteNameשם המרחב הווירטואלי של האתר, שמופיע בכתובת ה-URL של האתר (למשל, myCoolSite).

דוגמה לבקשה ולתשובה:

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

HTTP/1.1 200 OK

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

הערה: כדי לגשת לפיד הזה, אתם צריכים להיות שותפי עריכה או הבעלים של האתר. הלקוח צריך לשלוח את הכותרת הנכונה של Authorization ולהפנות לאסימון שהתקבל בהרשאת בקשות.

חזרה למעלה

פיד גרסאות

כדי לאחזר את היסטוריית הגרסאות של רשומת תוכן כלשהי, שולחים בקשת HTTP GET לקישור הגרסה של הרשומה:

https://sites.google.com/feeds/revision/domainName/siteName/CONTENT_ENTRY_ID
פרמטר של פידתיאור
domainName"site" או הדומיין של הדומיין המתארח ב-G Suite (למשל example.com).
siteNameשם המרחב הווירטואלי של האתר, שמופיע בכתובת ה-URL של האתר (למשל, myCoolSite).

כדי למצוא את הקישור לגרסאות של דף, תגובה, קובץ מצורף או פריט ברשימה, קודם מאחזרים את הרשומה מפיד התוכן באמצעות CONTENT_ENTRY_ID. הרשומה שאוחזרה תכיל <atom:link> לפיד הגרסאות. לדוגמה:

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

דוגמה לבקשה ולתשובה:

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

HTTP/1.1 200 OK

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

הערה: כדי לגשת לפיד הזה, אתם צריכים להיות שותפי עריכה או הבעלים של האתר. הלקוח צריך לשלוח את הכותרת הנכונה של Authorization ולהפנות לאסימון שהתקבל בהרשאת בקשות.

חזרה למעלה

פיד תוכן

מתבצע אחזור של התוכן

פיד התוכן מציג את התוכן הנוכחי של האתר. שולחים בקשת GET מאומתת לכתובת ה-URL הבאה:

https://sites.google.com/feeds/content/domainName/siteName
פרמטר של פידתיאור
domainName"site" או הדומיין של הדומיין המתארח ב-G Suite (למשל example.com).
siteNameשם המרחב הווירטואלי של האתר, שמופיע בכתובת ה-URL של האתר (למשל, myCoolSite).

התוצאה היא פיד שמציג את הדף הראשון של רשומות התוכן באתר. כל רשומה בפיד מייצגת סוג אחר של רשומת תוכן, כמו webpage,‏ filecabinet,‏ attachment,‏ comment וכו'. הרכיב <category scheme="http://schemas.google.com/g/2005#kind"> קובע את סוג הרשומה. במדריך העזר מופיעה רשימה של ערכי kind נתמכים.

הערה: יכול להיות שהפיד הזה ידרוש אימות, בהתאם להרשאות השיתוף של האתר. אם האתר לא ציבורי, הלקוח צריך לשלוח את הכותרת Authorization הנכונה (כמו בדוגמה שלמעלה) ולהפנות לאסימון שהתקבל בהרשאת בקשות.

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

HTTP/1.1 200 OK

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

הערה: אלה רק התוצאות הראשונות. כדי לעבור בין הדפים של פיד התוכן כולו, צריך לעבור לקישור "הבא" של הפיד:

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

להסבר על הרכיבים הנפוצים של Atom, אפשר לעיין בחומר העזר בנושא פרוטוקול הנתונים בחשבון Google. בהמשך מתוארים רכיבים שיש להם משמעות ספציפית ב-API של הגרסה הקלאסית של Google Sites. לרשומות מסוגים מסוימים יהיו מאפיינים נוספים (שלא מפורטים בהמשך), ולרשומות אחרות לא יהיו מאפיינים נוספים. לדוגמה, רשומה מסוג listitem יכולה להכיל רכיבים מסוג <gs:field>, אבל רשומה מסוג webpage לא יכולה להכיל אותם.

רכיבתיאור
<content ...>הטקסט הפנימי הוא גוף ה-HTML של הדף. בחלק מהרשומות (למשל, קבצים מצורפים), הרכיב הזה יכיל מאפיין src שמפנה לקובץ.
<link rel="alternate" ...>קישור לדף או לפריט ב-Google Sites.
<link rel="http://schemas.google.com/sites/2008#revision" ...>המאפיין href מפנה אל פיד הגרסאות של הרשומה.
<link rel="http://schemas.google.com/sites/2008#parent" ...>המאפיין href מפנה לרשומת ההורה של הרשומה.
<link rel="http://schemas.google.com/sites/2008#template" ...>המאפיין href מפנה לדף התבנית של הרשומה.
<category scheme="http://schemas.google.com/g/2005#kind" ...>‫label הוא סוג הרשומה.
<category term="http://schemas.google.com/g/2005#template" ...>label=template, שמציין שהרשומה היא תבנית.
<gd:feedLink>המאפיין href מצביע על הצאצאים של ההורה של הרשומה.
<sites:pageName>שם הדף במרחב האינטרנט, שתואם לשם בכתובת ה-URL של הדף.
<sites:revision>מספר הגרסה הנוכחית.

דוגמאות לשאילתות של פיד תוכן

אתם יכולים לחפש בפיד התוכן באמצעות חלק מהפרמטרים הרגילים של שאילתות Google Data API, וגם באמצעות פרמטרים ספציפיים ל-API של הגרסה הקלאסית של Google Sites. למידע מפורט יותר ולרשימה מלאה של הפרמטרים הנתמכים, עיינו במדריך העזר.

אחזור של סוגי רשומות ספציפיים

כדי לאחזר רק סוג מסוים של רשומה, משתמשים בפרמטר kind. בדוגמה הזו מוצגות רק רשומות של webpage:

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

כדי להחזיר יותר מסוג רשומה אחד, צריך להפריד בין כל kind באמצעות פסיק (','). בדוגמה הזו מוחזרות רשומות מסוג filecabinet ו-listpage:

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

לחלופין, אפשר להשתמש בפורמט הסטנדרטי של שאילתת הנתונים בחשבון Google /-/category במקום בפרמטר kind:

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

מאחזר את תבניות הדפים

בדוגמה הזו מוחזרים רק template דפים:

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

כדי להחזיר את כל סוגי הרשומות ולכלול template דפים, משתמשים ב:

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

אחזור דף לפי נתיב

אם אתם יודעים את הנתיב היחסי של דף ב-Google Sites, אתם יכולים להשתמש בפרמטר path כדי לאחזר את הדף הספציפי הזה. הדוגמה הזו תחזיר את הדף שנמצא בכתובת http://sites.google.com/site/siteName/path/to/the/page:

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

אחזור כל הרשומות בדף הורה

אם אתם יודעים את מזהה הרשומה של דף, אתם יכולים להשתמש בפרמטר parent כדי לאחזר את כל רשומות הצאצא שלו (אם יש כאלה):

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

כולל טיוטות או רשומות שנמחקו

כדי לכלול רשומות שנמחקו או רשומות טיוטה, משתמשים בפרמטרים include-drafts או include-deleted, בהתאמה. הדוגמה הזו כוללת רשומות של טיוטות בפיד התוכן:

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

חיפוש טקסט מלא

כדי לחפש בכל התוכן של אתר, משתמשים בפרמטר q כדי לבצע חיפוש טקסט מלא:

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

חזרה למעלה



יצירת תוכן

כדי ליצור תוכן חדש (דפי אינטרנט, דפי רשימות, דפי ארונות קבצים, דפי הודעות וכו'), שולחים בקשת HTTP POST לפיד התוכן:

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

רשימה של סוגי הרשומות הנתמכים מופיעה בפרמטר kind במדריך העזר.

יצירת פריטים או דפים חדשים

בדוגמה הזו נוצר webpage חדש ברמה העליונה של האתר, שכולל XHTML לגוף הדף, ומגדיר את הכותרת ל-"New WebPage Title":

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

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

אם הפעולה מצליחה, השרת משיב עם 201 Created ועותק של הרשומה.

יצירת פריטים או דפים בנתיבים של כתובות URL בהתאמה אישית

כברירת מחדל, הדוגמה הקודמת תיווצר בכתובת ה-URL‏ http://sites.google.com/domainName/siteName/new-webpage-title ותהיה לה כותרת דף בשם "כותרת חדשה לדף האינטרנט". כלומר, <atom:title> מנורמל ל-new-webpage-title בכתובת ה-URL. כדי להתאים אישית את נתיב כתובת ה-URL של דף, אפשר להגדיר את הרכיב <sites:pageName>.

בדוגמה הזו נוצר filecabinet חדש עם כותרת הדף "אחסון קבצים", אבל הדף נוצר בכתובת ה-URL‏ http://sites.google.com/domainName/siteName/files על ידי ציון הרכיב <sites:pageName>.

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

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

השרת משתמש בכללי הקדימות הבאים כדי לתת שם לנתיב כתובת ה-URL של הדף:

  1. ‫<sites:pageName>, אם הוא קיים. חייב לעמוד בתנאי a-z, A-Z, 0-9, -, _.
  2. <atom:title>, לא יכול להיות null אם pageName לא קיים. הנורמליזציה כוללת חיתוך וצמצום של רווחים ל-'-' והסרת תווים שלא תואמים ל-a-z, A-Z, 0-9, -, _.

לדוגמה, השרת יקבל את הערך "Custom_Page2".

יצירת דפי משנה

כדי ליצור דפי משנה (צאצאים) מתחת לדף הורה, צריך לכלול <link rel="http://schemas.google.com/sites/2008#parent"> ברשומת Atom החדשה. מגדירים את המאפיין href של הקישור לקישור העצמי של רשומת ההורה.

בדוגמה הזו נוצר announcement חדש עם הכותרת "announcement", מתחת לדף הודעות הורה עם מזהה הרשומה PARENT_ENTRY_ID. הוא כולל גם תוכן XHTML של גוף הדף:

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

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

תבניות של דפים

יצירת תבניות לדפים

התהליך ליצירת תבנית דף זהה ליצירת פריטים/דפים חדשים ויצירת דפי משנה.ההבדל הוא הוספת category עם מונח ותווית שמוגדרים ל-'http://schemas.google.com/g/2005#template' ול-'template', בהתאמה.

בדוגמה הזו נוצרת תבנית webpage חדשה.

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

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

יצירת דפים מתבנית

בדומה ליצירת תבניות דפים, אפשר ליצור דף חדש מתבנית על ידי הכללת <link> עם rel='http://schemas.google.com/sites/2008#template' שמצביע על הקישור העצמי של תבנית דף.

בדוגמה הזו יוצרים דף filecabinet חדש מתבנית דף קיימת שמגדירה ארון קבצים.

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

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

הערה: למרות שהתבנית מגדירה <category>, עדיין צריך לכלול אחד ברשומה. חשוב גם לדעת שאם תכללו רכיב <content>, השרת ידחה אותו.

העלאת קבצים

בדיוק כמו ב-Google Sites, ה-API מאפשר להעלות קבצים מצורפים לדפי ספריית קבצים ולדפי הורה.

כדי להעלות קובץ מצורף להורה, שולחים בקשת HTTP POST לכתובת ה-URL של פיד התוכן:

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

גוף ה-POST צריך להיות בקשת MIME מרובת חלקים, כדי לשלב את תוכן הקובץ עם <atom:entry> שמכיל את המטא-נתונים של הקובץ המצורף. השדה <atom:entry> צריך להפנות לקישור העצמי של רשומת ההורה, כדי לציין איפה הקובץ המצורף ייווצר. מידע נוסף זמין במאמר יצירת דפי משנה.

הקבצים מועלים

דוגמה להעלאת קובץ PDF לספריית קבצים עם המזהה PARENT_ENTRY_ID. הקובץ המצורף ייווצר עם הכותרת "קובץ PDF" והתיאור (האופציונלי) "חבילת משאבי אנוש".

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

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

--END_OF_PART
Content-Type: application/pdf

... pdf contents here ...

--END_OF_PART--

אם ההעלאה תצליח, השרת יחזיר את הקוד 201 Created ועותק של רשומת הקובץ המצורף החדש שנוצר.

העלאת קובץ מצורף לתיקייה

כדי להעלות קובץ מצורף לתיקייה קיימת ב-filecabinet, צריך לכלול קטגוריה עם המאפיין "term" שמוגדר לשם התיקייה:

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

קבצים מצורפים מהאינטרנט

קבצים מצורפים מהאינטרנט הם סוגים מיוחדים של קבצים מצורפים. בעצם, אלה קישורים לקבצים אחרים באינטרנט שאפשר להוסיף לרשימות של ארון הקבצים. התכונה הזו דומה לשיטת ההעלאה "הוספת קובץ לפי כתובת URL" בממשק המשתמש של Google Sites.

הערה: אפשר ליצור קבצים מצורפים מהאינטרנט רק בספריית קבצים. אי אפשר להעלות אותם לסוגים אחרים של דפים.

בדוגמה הזו נוצר webattachment בתוך תיקיית הקבצים שמזוהה באמצעות המזהה FILECABINET_ENTRY_ID. הכותרת והתיאור (האופציונלי) שלו מוגדרים כ-"GoogleLogo" ו-"nice colors", בהתאמה.

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

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

ה-POST יוצר קישור בארון הקבצים של המשתמש שמפנה לתמונה בכתובת http://www.google.com/images/logo.gif.

חזרה למעלה



עדכון התוכן

אפשר לערוך את המטא-נתונים (כותרת, שם הדף וכו') ואת התוכן של כל דף באמצעות בקשת PUT אחת לקישור edit. גוף הבקשה צריך להכיל רשומת Atom שמתארת את הדף המעודכן. החריג לכלל הזה הוא רשומת קובץ מצורף, שבה אפשר להשתמש ברשומה רק כדי לעדכן את המטא-נתונים של הקובץ המצורף. כדי לשנות את התוכן של הקובץ המצורף, פשוט כוללים את הנתונים הגולמיים כגוף של בקשת PUT לקישור edit-media של הקובץ המצורף. אפשר גם לעדכן את המטא-נתונים ואת תוכן הקובץ המצורף בו-זמנית באמצעות בקשת MIME מרובת חלקים.

כדי לוודא שהעדכון לא מחליף שינויים של לקוח אחר, צריך לכלול את ערך ה-ETag של הרשומה המקורית. כדי לעשות את זה, צריך לספק את הערך של ETag בכותרת HTTP If-Match, או לכלול את המאפיין gd:etag של הרשומה המקורית ברשומה המעודכנת. כדי לקבוע את ערך ה-ETag של הרשומה המקורית, בודקים את המאפיין gd:etag של הרכיב <entry>. ברשומות מדיה, יכול להיות שה-ETag של המדיה יהיה זמין במאפיין gd:etag של הקישור edit-media.

אם אתם רוצים לעדכן את הרשומה בלי קשר לשאלה אם מישהו אחר עדכן אותה מאז שאחזרתם אותה, השתמשו ב-If-Match: * ואל תכללו את ה-ETag. מידע נוסף על תגי ETag זמין במדריך העזר של Google Data APIs.

עדכון המטא-נתונים או תוכן ה-HTML של פריט

כדי לעדכן את המטא-נתונים או את תוכן ה-HTML של רשומה, שולחים בקשת HTTP PUT לקישור edit של הרשומה.

הנה דוגמה לעדכון רשומה של listpage (המיוצגת על ידי המזהה שלה ENTRY_ID) עם השינויים הבאים:

  • הכותרת משתנה ל"תוכן מעודכן"
  • תוכן HTML מעודכן
  • הכותרת של העמודה הראשונה ברשימה משתנה ל"בעלים".
  • נתיב כתובת ה-URL של הדף משתנה על ידי הרכיב <sites:pageName>
PUT /feeds/content/domainName/siteName/ENTRY_ID
Host: sites.google.com
GData-Version: 1.4
Authorization: <your authorization header here>
Content-Length: 816
Content-Type: application/atom+xml

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

הערה: הרשומה (כפי שהיא מוחזרת על ידי השרת) תכיל יותר רכיבים מהדוגמה שלמעלה.

החלפת התוכן של קובץ מצורף

בדוגמה הבאה מוצגת החלפה של תוכן הקובץ המצורף, אבל המטא-נתונים שלו נשארים ללא שינוי. מכיוון שהבקשה מכילה תוכן חדש, המערכת משתמשת בקישור edit-media של רשומת הקובץ המצורף.

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

... doc contents here ...

עדכון המטא-נתונים והתוכן של הקובץ המצורף

בדוגמה הבאה מוצג עדכון של המטא-נתונים של הקובץ המצורף ושל התוכן שלו בו-זמנית. שם הקובץ המצורף יעודכן ל-"New Title" והתוכן שלו יוחלף בתוכן של קובץ ‎ .zip. מכיוון שהבקשה מכילה תוכן של קובץ חדש, נעשה שימוש בקישור edit-media של רשומת הקובץ המצורף.

שימו לב שהכללת ה-ETag של המטא-נתונים מספקת If-Match משתמע גם לתוכן המדיה, כי כל עדכון של תוכן המדיה גורם לשינוי של ה-ETag של המטא-נתונים.

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

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

--END_OF_PART
Content-Type: application/zip

... zip contents here ...

--END_OF_PART

חזרה למעלה



מחיקת תוכן

כדי להסיר פריט מאתר ב-Google Sites, קודם מאחזרים את הרשומה ואז שולחים בקשת DELETE לכתובת ה-URL של הרשומה edit. זו אותה כתובת URL שמשמשת לעדכון המטא-נתונים או תוכן ה-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>

אם הרשומה נמחקה בהצלחה, השרת יחזיר את קוד הסטטוס 200 OK של HTTP.

כדי לוודא שלא תמחקו רשומה ששונתה על ידי לקוח אחר מאז שאחזרתם אותה, צריך לכלול כותרת HTTP If-Match שמכילה את ערך ה-ETag של הרשומה המקורית. כדי לקבוע את ערך ה-ETag של הרשומה המקורית, בודקים את המאפיין gd:etag של הרכיב <entry>.

אם אתם רוצים למחוק את הרשומה גם אם מישהו אחר עדכן אותה מאז שאחזרתם אותה, השתמשו ב-If-Match: * ואל תכללו את ה-ETag. (במקרה כזה, לא צריך לאחזר את הרשומה לפני שמוחקים אותה).

מידע נוסף על תגי ישות זמין במדריך העזר של Google Data APIs.

חזרה למעלה



הורדת קבצים מצורפים

אחרי שיוצרים רשומת קובץ מצורף, אפשר להוריד את הקובץ על ידי שליחת בקשת HTTP GET מאומתת לקישור src של הרשומה <content>. דוגמה לקישור לתוכן של קובץ PDF:

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

חזרה למעלה

פיד ACL

סקירה כללית של הרשאות השיתוף (רשימות ACL)

כל רשומת ACL בפיד ה-ACL מייצגת תפקיד גישה של ישות מסוימת, בין אם מדובר במשתמש, בקבוצת משתמשים, בדומיין או בגישה שמוגדרת כברירת מחדל (אתר ציבורי). הרשומות יוצגו רק לישויות עם גישה מפורשת – רשומה אחת תוצג לכל כתובת אימייל בחלונית "אנשים עם גישה" במסך השיתוף של ממשק המשתמש ב-Google Sites. לכן, אדמינים של דומיינים לא יוצגו, למרות שיש להם גישה משתמעת לאתר.

תפקידים

רכיב התפקיד מייצג את רמת הגישה שיכולה להיות לישות. יש ארבעה ערכים אפשריים לרכיב gAcl:role:

  • reader – צופה (מקביל להרשאת קריאה בלבד).
  • writer – שותף עריכה (שווה ערך לגישת קריאה/כתיבה).
  • בעלים – בדרך כלל האדמין של האתר (שווה ערך לגישת קריאה/כתיבה).

היקפים

הרכיב scope מייצג את הישות שיש לה את רמת הגישה הזו. יש חמישה סוגים אפשריים של הרכיב gAcl:scope:

  • user – ערך של כתובת אימייל, למשל user@gmail.com.
  • ‫group – כתובת אימייל של קבוצה ב-Google, למשל group@domain.com.
  • domain — שם דומיין ב-G Suite, לדוגמה "domain.com".
  • invite – משתמש שהוזמן לאתר, אבל עדיין לא נוסף ל-ACL של האתר. (לא זמין אם צוין gdata 1.3 או גרסה קודמת).
  • ‫default — יש רק היקף אחד אפשרי מסוג default, שאין לו ערך (למשל <gAcl:scope type="default">). ההיקף הספציפי הזה קובע את הגישה שיש לכל משתמש כברירת מחדל באתר ציבורי.

הערה: אי אפשר להגדיר לדומיינים ערך gAcl:role עם גישת "בעלים", אלא רק קוראים או כותבים.

מידע על היקף ההרשאות "הזמנה".

ה-API מחזיר את היקף ההזמנה כשמוסיפים ל-ACL משתמש אחד או יותר שאין להם חשבון Google. ה-API מחזיר כתובת URL עם אסימון מוטמע שצריך לספק למשתמשים שהוזמנו כדי לאפשר להם לאשר את ההזמנה.

שיטת ההזמנה הזו מאפשרת לכם להזמין משתמשים בלי חשבון Google, בלי לדעת מראש באיזו כתובת אימייל הם רוצים להשתמש. כל עוד המשתמשים לוחצים על כתובת ה-URL של ההזמנה עם האסימון המוטמע, הם יכולים להירשם כדי לקבל גישה באמצעות כל כתובת אימייל שהם רוצים. בנוסף, כמה משתמשים יכולים להשתמש בכתובת ה-URL הזו כדי לאשר את ההזמנה, כך שהיא יכולה להיות שימושית אם מזמינים משתמש אחד או קבוצה של משתמשים.

הערה: ההיקף "invite" זמין רק ב-gdata בגרסה 1.4 ואילך. הפעולה הזו לא תעבוד אם אתם מציינים במפורש את גרסה 1.3 או גרסה קודמת.

אחזור הפיד של רשימת ה-ACL

אפשר להשתמש בפיד של רשימת ה-ACL כדי לשלוט בהרשאות השיתוף של האתר, וניתן לגשת אליו דרך ה-URI הבא:

https://sites.google.com/feeds/acl/site/domainName/siteName
פרמטר של פידתיאור
domainName"site" או הדומיין של הדומיין המתארח ב-G Suite (למשל example.com).
siteNameשם המרחב הווירטואלי של האתר, שמופיע בכתובת ה-URL של האתר (למשל, myCoolSite).

חשוב לציין שכל רשומה בפיד האתר מכילה קישור לפיד הזה:

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

כדי לאחזר את הרשאות השיתוף של אתר, שולחים בקשת HTTP GET ל-URI של פיד ה-ACL:

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

השרת יגיב עם 200 OK ופיד של רשומות ACL:

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

חזרה למעלה

שיתוף אתר

פיד ה-ACL מקבל בקשות מסוג GET,‏ POST ו-PUT. כדי להוסיף תפקיד חדש לפיד ה-ACL, פשוט שולחים בקשת POST לפיד ה-ACL של האתר.

הערה: יכול להיות שרשימות ACL מסוימות לשיתוף יהיו אפשריות רק אם הדומיין מוגדר לאפשר הרשאות כאלה (למשל, אם מופעל שיתוף מחוץ לדומיין בדומיינים של G Suite וכו').

בדוגמה הזו מוסיפים לאתר שותף עריכה חדש (כותב):

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

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

אם ההוספה תצליח, יוחזרו 201 Created והרשומה החדשה:

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

הזמנת משתמשים באמצעות ההיקף "הזמנה"

אם אתם מוסיפים משתמשים שאין להם חשבונות Google, ה-API מחזיר כתובת URL שאתם צריכים לספק למשתמשים שאתם רוצים להזמין. אחרי שהם ילחצו על כתובת ה-URL, הם יוכלו להיכנס לאתר באמצעות חשבון קיים או ליצור חשבון חדש.

אם ההזמנה תצליח, יוחזר 201 Created ורשומה חדשה שתכלול את כתובת ה-URL שצריך להעביר למשתמש:

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

שיתוף ברמת הקבוצה והדומיין

בדומה לשיתוף אתר עם משתמש יחיד, אתם יכולים לשתף אתר עם קבוצת Google או עם דומיין G Suite. ערכי scope הנדרשים מפורטים בהמשך.

שיתוף עם כתובת אימייל של קבוצה:

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

שיתוף עם דומיין שלם:

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

שיתוף ברמת הדומיין נתמך רק בדומיינים של G Suite, ורק בדומיין שבו האתר מתארח. לדוגמה, אתר בכתובת http://sites.google.com/a/domain1.com/siteA יכול לשתף את האתר כולו רק עם domain1.com, ולא עם domain2.com. אתרים שלא מתארחים בדומיין של G Suite (למשל, http://sites.google.com/site/siteB) לא יכולים להזמין דומיינים.

שינוי הרשאות השיתוף

כדי לעדכן רשומה של רשימת ACL, משנים את הרשומה לפי הצורך ושולחים בקשת HTTP PUT לקישור edit של הרשומה, שהוא פשוט רכיב <link> שהמאפיין rel שלו מוגדר כ-edit. בדוגמה הקודמת, הקישור הוא:

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

קטע הקוד הבא משנה את התפקיד של new_writer@gmail.com ל"קורא":

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>

הסרת הרשאות שיתוף

כדי להסיר את ההרשאות של המשתמש הזה, שולחים בקשת DELETE לאותו קישור edit ששימש לבקשת ה-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>

השרת ישיב עם 200 OK.

חזרה למעלה

נושאים מיוחדים

אחזור מחדש של פיד או רשומה

אם אתם רוצים לאחזר פיד או רשומה שאחזרתם בעבר, אתם יכולים לשפר את היעילות על ידי כך שתורו לשרת לשלוח את הרשימה או הרשומה רק אם היא השתנתה מאז הפעם האחרונה שאחזרתם אותה.

כדי לבצע אחזור מותנה כזה, שולחים בקשת HTTP GET שכוללת כותרת HTTP If-None-Match. בכותרת, מציינים את ה-ETag של הרשימה או של הרשומה, שאפשר למצוא במאפיין gd:etag של הרכיב <feed> או של הרכיב <entry>.

דוגמה לשימוש בפיד האתר:

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

כשהשרת מקבל את הבקשה הזו, הוא בודק אם לפריט שביקשתם יש את אותו ETag כמו ה-ETag שציינתם. אם תגי ה-ETag תואמים, הפריט לא השתנה והשרת מחזיר קוד סטטוס HTTP 304 Not Modified או קוד סטטוס HTTP 412 Precodition Failed. שני קודי הסטטוס האלה מציינים שהפריט שכבר אחזרתם מעודכן.

אם תגי ה-ETag לא תואמים, סימן שהפריט השתנה מאז הפעם האחרונה שביקשתם אותו, והשרת מחזיר את הפריט.

מידע נוסף על תגי ישות זמין במדריך העזר של Google Data APIs.

עיבוד באצווה (batch processing)

בקשות Batch מאפשרות ללקוח לבצע כמה פעולות בבקשה אחת, במקום לשלוח כל פעולה בנפרד.

השרת יבצע כמה שיותר מהשינויים שביקשתם ויחזיר מידע על הסטטוס, שבעזרתו תוכלו להעריך את ההצלחה או הכישלון של כל פעולה. לפרטים נוספים על עיבוד באצווה ב-Google Data API, עיינו במאמר עיבוד באצווה באמצעות Google Data APIs.

לכל פעולה בפיד באצ' יש רכיב <id>, חוץ מפעולות הוספה. הרכיב הזה זהה לכתובת ה-URL של הבקשה שבה משתמשים בדרך כלל כשמעדכנים, מוחקים או שולחים שאילתה לגבי פיד התוכן. לדוגמה, אם אתם מעדכנים עריכה, הגדירו את <id> לקישור edit של הרשומה הרלוונטית. הוא משמש לזיהוי רשומת היעד. לרשומות חדשות אין רכיבי <id> כי הן עדיין לא נוצרו. במקום זאת, אפשר להגדיר ערך מחרוזת ב-<batch:id>, שיוחזר בתגובת השרת וישמש לחיפוש הרשומה המתאימה.

כדי לשלוח בקשת Batch, יוצרים פיד אצווה ושולחים בקשת HTTP POST לקישור האצווה של הפיד:

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

בדוגמה הבאה אפשר לראות איך שולחים שאילתה, מוסיפים, מעדכנים ומוחקים רשומה של דף אינטרנט:

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

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

הפיד שיוחזר יכיל רשומת תוצאה אחת לכל פעולה:

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

חזרה למעלה