Monday, March 9, 2015
Control your Google Sites from Apps Script
Henry Lau, on the Google Apps Script team, has written a great tutorial on Creating a Soccer Club Homepage. In short, his script pulls upcoming Soccer matches from Google Calendar, creates a Google Site about the team and adds the Soccer team from Contacts as collaborators. Heres some snippets of the code.
// create a site, given the domain, site URL, site title and summary
var site = SitesApp.createSite("example.com", "rover", "Team Rover", "Well be the divisional champs this year!");
// create a page for each member of the team
var webpage = site.createWebPage("Jimmys Page", "JimmysPage", "Welcome to Jimmys site");
var webpage = site.createWebPage("Jimmys Page", "JimmysPage", "Welcome to Jimmys site");
// create a page for team announcements
var annPage = site.createAnnouncementsPage("Team Announcements", "Announcements", "New announcements for the team will be posted here.");
var annPage = site.createAnnouncementsPage("Team Announcements", "Announcements", "New announcements for the team will be posted here.");
// given one of the Google Calendar events, create an announcement
var message = "There will be a soccer match from " + event.getStartTime() + " until " + event.getEndTime() + "!";
site.createAnnouncement("Soccer Match #1", message, annPage);
site.createAnnouncement("Soccer Match #1", message, annPage);
Its that easy! Check out the documentation and get started building your scripts.
Of course, if you decide that youd rather create Google Sites via a REST interface, the recently-announced enhancements to the Sites Data API will allow you to write code in your language of choice to create and manage sites.
Ryan Boyd
Developer Relations - Google Apps
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.