Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expanding the gDocs JSON call to accept variables #20

Open
dhornbein opened this issue Apr 15, 2014 · 1 comment
Open

Expanding the gDocs JSON call to accept variables #20

dhornbein opened this issue Apr 15, 2014 · 1 comment

Comments

@dhornbein
Copy link
Owner

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.

@thiagodemellobueno
Copy link
Collaborator

Why not a little gear icon, which pops up a modal with a “Add you spreadsheets share link here" and then someone just pastes the spreadsheet URL?
We can parse out the info we need.

And theres no hard coding, I don’t think we should support sheets for MVP.

On Apr 15, 2014, at 4:32 PM, Drew [email protected] wrote:

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&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.


Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants