Services‎ > ‎Desktop Liberation‎ > ‎

Delegation to Google Apps Script

Step by Step guide for Google Apps Script proxying

In a number of articles I've covered how to use GAS for jsonp, oauth, as a lockbox  and various other useful things. There are many threads to pull together in this section, so here's a step by guide to GAS proxying as described in this post.

Here's a schematic of the various themes we'll cover

delegating to the cloud

Two examples of publishers

We will cover 2 examples in this guide, then show how to access them from a variety of external sources. 
  1. Retrieving some data by parameter from an Apps Script ScripDB,  and returning a jSon response.
  2. Executing a existing mashup and enhancing it, and returning a jSon response

Steps for first example - retrieve data from scriptDB

Most of the code that is referred to in these serious of posts is available in the mcpher shared library.  Please add this library to all any scripts you create.
  1. Create a blank script project, pubstuff, and add the mcpher library. See Using the mcpher library in your code.
  2. Create a second script project, storeinscriptdb, and add the mcpher library. See Using the mcpher library in your code.
  3. pubstuff will host the scriptDB in which you are going to publish all your public data. To create and publish an app to get access to a public scriptDB, follow Hosting your public scriptdb
  4. In storeinscriptdb, create a module to store some data that we will retrieve later. See Store data in scriptdb for how.
Now we can put the whole thing together. Using the url of your published app from pubstuff, which you created in Hosting your public scriptdb, you can now enter that in a browser with a parameter of ?entry=favorites appended to the Url. You should get a result like that from  my implementation of this step by step so far.  
    {
        "status": {
            "code": "good",
            "reason": "favorites found in your stuff"
        },
        "results": [
            {
                "siloId": "favorites",
                "help": "for details see ramblings.mcpher.com",
                "timeStamp": 1352116547560,
                "myStuff": [
                    {
                        "name": "excel liberation",
                        "url": "ramlings.mcpher.com"
                    },
                    {
                        "name": "liberation blog",
                        "url": "excelramblings.blogspot.com"
                    }
                ],
                "userStamp": "bruce@mcpher.com"
            }
        ]
    }

    Steps for second example - enhancing a mashup

    Most of the code that is referred to in these serious of posts is available in the mcpher shared library.  Please add this library to all any scripts you create. In this example, we are going to take the urbarama mashup, which already uses google apps script to combine 2 APIS, and create another API which refines the result of that and returns the refined results.
    1. Create a blank script project, urbenhanced, and add the mcpher library. See Using the mcpher library in your code.
    2. in urbenhanced, we need to write some code that will execute the original urbabarama mashup as rest query, but will manipulate the results and publish the manipulated results instead. See Enhancing the urbarama mashup for how.
    Now we have an enhanced urbarama mashup. Here's my implementation of this example with a couple of parameters appended.

    Using the public scriptdb to manage your URLs

    Now that we have a couple of publishers, the next step is to use the scriptDB to store an accessible version of your growing library of published apps
    For help and more information join our forum,follow the blog or follow me on twitter . Now take a look at some selected detail in some of these topics.

    Here's another example of GAS delegation - this time useing built in XML.parse to convert XML to JSON and pulling it back to Excel