Using Google Spreadsheet forms with Flash

Saturday, August 2nd, 2008 | Actionscript 2, Actionscript 3

Overview

Google Spreadsheet forms are an ideal way to collect information from users, like messages, comments or feedback. You don’t need to do any work on your part to store it, no databases, files or anything like that. It relies only on the fact that you have a google account, and can put together a very simple spreadsheet form.

As a very simple example, if you were making a flash site for a client and wanted to put in a contact form that users could add messages to a stored list, then this would be an ideal way to provide a solution that you wouldn’t have to maintain, and that your client would have instant access to in an easy format. They can even output it to excel.

Format

All you need to do is pass in your LoadVars or URLVariables in post format variables like this:

sender["entry.0.single"]  = “my string to add to spreadsheet”;

Where the number between entry and single is an incrementing number denoting the control in the form to mirror. So in this example the entry.0.single represents the name text field control in the google spreadsheet form.

Crossdomain and php proxy

Unfortunately the google spreadsheets crosssdomain.xml does not allow flash content to access the spreadsheets url but by using a fairly simple php proxy we can easily get round this.

So the LoadVars/URLLoader calls the local GoogleSpreadsheetProxy.php passing all the vars and the url for submitting the spreadsheet and simply proxys the request via the url passed.

Spreadsheet document the example feeds into:

http://spreadsheets.google.com/ccc?key=pyxyLmVwUP3PhX7wp6GV_SQ&hl=en

Example:

Source Code Flavours:

Download As2 Flash 8 Version .zip

Download As3 Flash 9 Version .zip

Tags: , , ,

7 Comments to Using Google Spreadsheet forms with Flash

Ugo
January 21, 2009

Thanks for this. I’m considering using this for the comments/message board system of a flash based blog. I have a couple of questions though:

How secure is this method? Is it best to try and implement spam filtering on the flash side or from the php/server side?

I’m quite familiar with AS3 but have less than a basic understanding of php. Is there a sample code for retrieving data from the google spread sheet to be sent back to flash?

admin
January 28, 2009

It’s really a one sided way of storing data. There are ways of retrieving the data from a google spreadsheet. You’d have to “screen scrape”, here’s an example: http://matthewsteele.wordpress.com/2007/11/03/screen-scraping-google-spreadsheets-exported-as-html/

To be honest it sounds like you’d be better off just using an off the shelf comments/message board system plugged into a database and save your time for doing something more interesting, rather than reinventing the wheel.

[...] so I wouldn’t recommend deploying it on a public server. I got my script from a post on Aden Forshaw’s blog. In the real world you would want to have some security token to limit access to your proxy [...]

denis
February 16, 2009

Very interesting, but doesnt work in this moment?!?

do you see Sprout can import a Google Form?
how does it work??

admin
February 17, 2009

I’d try the latest example i’ve made http://www.adenforshaw.co.uk/?p=196

Sprout looks quite funky, it looks like they’ve done the sort of thing i’ve done here with the google forms.
I’m doing something kind of similar to sprout which is partly why i’m doing all these proof of concept examples and giving them away for free.

adi imam pratomo
January 22, 2010

Love this post! Thanks for this. I

Carlos
March 20, 2010

Is this working? I’ve been trying to do this, but I can’t. Thanks for your help

Leave a comment

Search

Subscribe