Today, we are excited to make Google Apps Script available to everyone. Some of you may already be familiar with Google Apps Script within Google Apps, but in case you are new to it,

provides a powerful and flexible scripting environment that lets you automate actions across your spreadsheets, sites, calendars, and many other services.

An important new feature of Apps Script is a script gallery, where developers can easily publish their scripts to make them accessible to everyone. You can find the gallery by going to

Insert

and then selecting

Script...

in any Google spreadsheet.

Recently, the Google Apps team in New York put together a

Movie Night

script to help us easily figure out which movies were playing nearby and vote for our favorites - you can read more about it

here

. Let’s take a closer look at how the script works and how we published it to the new Apps Script Gallery.

We start by bringing up the script editor from a spreadsheet (

Tools -> Scripts -> Script editor...

).

The first step is to fetch a list of movies playing in a given area at a given time. We use the Google search results for a movie query as follows:

var

results = UrlFetchApp.fetch(

'http://www.google.com/movies?hl=en&near='

+

zipcode +

'&dq=movies&sort=1'

).getContentText();

var

doc = Xml.parse(results,

true

);

We can then use Apps Script’s handy

to parse the results. The next step is to send an email to our friends asking them to vote. This is the slightly tricky part: