Skip to content

Expanding the gDocs JSON call to accept variables #20

@dhornbein

Description

@dhornbein

The current method for calling the published Google spreadsheet is this:
<script src="http://spreadsheets.google.com/feeds/list/1CWmIrQ9Ic1R81kpFg2eCL21dH-XLeBkRkqMnOWDlDuk/0/public/values?alt=json-in-script&amp;callback=phenClockGDImport"></script>

See Google's Simple example of retrieving JSON feeds from Spreadsheets Data API

The src URL has two a few important URI components (to us) which you can read in detail about in the link above.

http://spreadsheets.google.com/feeds/**feed**/**key**/**worksheet**/public/basic?alt=json-in-script&callback=myFunc

key is the long string of numbers and symbols that make up the unique identifier for the spreadsheet. I know of three ways we would take this key as input.

The Google drive link when you are editing the spreadsheet: https://docs.google.com/spreadsheets/d/1CWmIrQ9Ic1R81kpFg2eCL21dH-XLeBkRkqMnOWDlDuk/edit#gid=0

The publish link for the HTML version: https://docs.google.com/spreadsheets/d/1CWmIrQ9Ic1R81kpFg2eCL21dH-XLeBkRkqMnOWDlDuk/pubhtml

And simply the key itself: 1CWmIrQ9Ic1R81kpFg2eCL21dH-XLeBkRkqMnOWDlDuk

I believe the length will always be 32 characters so a regex like this should work: [a-z0-9_-]{32,}

worksheet is the name (and/or?) number of the sheet within the document. I've tried to swap out spreadsheets only to have them return a 400 error because I didn't take the sheet into account.

It appears the 0 is the default. So any input could simply have an optional sheet input as well. e.g. [ input key here ] [sheet # ]

Ideas on how to manage key

I think that there could simply be a variable in the index.html that holds the key an worksheet values.

We could also check for a hash value in the URL:

http://phenclock.org/pclock/index.html#1CWmIrQ9Ic1R81kpFg2eCL21dH-XLeBkRkqMnOWDlDuk

or a variable pair:

http://phenclock.org/pclock/index.html?key=1CWmIrQ9Ic1R81kpFg2eCL21dH-XLeBkRkqMnOWDlDuk&worksheet=1

Which will allow us to accept the worksheet too.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions