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

ממשק ה-Sites API הקלאסי של Google מאפשר לאפליקציות שלכם לגשת לתוכן באתר שנוצר באמצעות 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. (אם ה-API לא מופיע ב-קונסולה לממשקי API, אפשר לדלג על השלב הזה).
  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
פרמטר של פידתיאור
domainNamesite' או הדומיין המתארח שלכם ב-G Suite (למשל, example.com).

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

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

HTTP/1.1 200 OK

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

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

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

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

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

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

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

הבקשה שלמעלה תיצור אתר חדש ב-Google Sites עם העיצוב 'slate' בדומיין 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.

אפשר לשכפל אתר קיים באותו אופן שבו יוצרים אתר חדש. עם זאת, ברשומה של 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>

בדוגמה הזו נוספות שתי קטגוריות: Team Site (אתר צוות) ו-Legal Department (מחלקה משפטית).

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

מיפויים של כתובות אינטרנט מאפשרים למשתמשי 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.

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

הערה: כשעובדים עם מיפויים של כתובות אינטרנט, צריך לציין את הפרמטר with-mappings=true בכל הפעולות מסוג GET,‏ POST או PUT. אם הפרמטר לא קיים, המערכת לא תחזיר את webAddressMappings ברשומות של אתרים (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
פרמטר של פידתיאור
domainNamesite' או הדומיין המתארח שלכם ב-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
פרמטר של פידתיאור
domainNamesite' או הדומיין המתארח שלכם ב-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 הנכונה ולהפנות לטוקן שהתקבל באישור הבקשות.

חזרה למעלה

פיד תוכן

אחזור תוכן

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

https://sites.google.com/feeds/content/domainName/siteName
פרמטר של פידתיאור
domainNamesite' או הדומיין המתארח שלכם ב-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 Data Protocol. בהמשך מפורטים רכיבים שיש להם משמעות ספציפית ב-Sites 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 ופרמטרים שספציפיים ל-Sites API הקלאסי. מידע מפורט יותר ורשימה מלאה של הפרמטרים הנתמכים זמינים במדריך העזר.

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

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

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

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

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

אפשרות אחרת היא להשתמש בפורמט הסטנדרטי לשאילתת Google Data /-/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 וכותרת דף 'New Webpage Title'. כלומר, <atom:title> מנורמלת ל-new-webpage-title בכתובת ה-URL. כדי להתאים אישית את נתיב כתובת ה-URL של דף, אפשר להגדיר את רכיב <sites:pageName>.

בדוגמה הזו נוצר filecabinet חדש עם כותרת הדף 'File Storage', אבל הדף נוצר בכתובת 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 multipart, כדי לשלב את תוכן הקובץ עם <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 multipart.

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

אם רוצים לעדכן את הרשומה בלי קשר לשאלה אם מישהו אחר עדכן אותה מאז שאחזרתם אותה, צריך להשתמש ב-If-Match: * ולא לכלול את ה-ETag. מידע נוסף על ETags זמין במדריך ההפניה של 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 ...

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

בדוגמה הבאה מוצג עדכון של המטא-נתונים והתוכן של קובץ מצורף בו-זמנית. השם של הקובץ המצורף יעודכן ל 'שם חדש' והתוכן שלו יוחלף בתוכן של קובץ 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>

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

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

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

מידע נוסף על ETags זמין במדריך בנושא Google Data APIs.

חזרה למעלה



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

אחרי שמוסיפים רשומה של קובץ מצורף, אפשר להוריד את הקובץ על ידי שליחת HTTP מאומת GET לקישור <content> src של הרשומה. דוגמה לקישור לתוכן של קובץ 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 – צופה (מקביל להרשאת קריאה בלבד).
  • כותב – שותף עריכה (שווה ערך לגישת קריאה/כתיבה).
  • בעלים – בדרך כלל האדמין של האתר (שווה ערך לגישת קריאה/כתיבה).

טווחים

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

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

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

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

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

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

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

אחזור פיד ה-ACL

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

https://sites.google.com/feeds/acl/site/domainName/siteName
פרמטר של פידתיאור
domainNamesite' או הדומיין המתארח שלכם ב-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>

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

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

מידע נוסף על ETags זמין במדריך בנושא Google Data APIs.

עיבוד באצווה

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

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

לכל פעולה בפיד של קבוצת פעולות יש רכיב <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>

חזרה למעלה