I had initially held off answering this one, as I don't know anything about the Google Apps Script API, but I just looked at the link you posted and thought "How hard can it be?"
Famous last words?
Anyway, googling "http://www.google.com/search?q=Google+Apps+Script+API+tutorial" gives you this as a first result.
Is this what you are looking for, or have I missed the mark completely.
The rest of the results from the above query seem quite promising too, for example this one: Automate Google Analytics Reporting using Google Apps Script
That help any?