So I'm working on a google gadget(really only gadgetizing so I can get a datastore for this) that I want to be embeddable in a google spreadsheet (after this point, I'm going to skip the word google - you can just imagine it's there).
I want to use the spreadsheet that I embed the gadget in as a key/value store for the data I enter within the gadget (I think the 2K limit for gadget data won't be enough). It looks like what I'll want to do is use the gadget's feed api to manipulate the
spreadsheet's list feed. However, in order to know what the spreadsheet's list feed is, I need to know the key for the spreadsheet (which is in the URL). I don't think I can scrape the key directly from the URL, since the gadget seems to be inserted via iframe.
So I need to know how I can tell a gadget that I'm embedding in a spreadsheet the key for that spreadsheet. I suppose I could have the user enter it manually, but I'd much rather have my gadget know the key programmatically.
You might want to try using Google Apps Script instead of a gadget. It is aware of the spreadsheet it is embedded on.
http://code.google.com/googleapps/appsscript/
You should be able to retrieve a list of spreadsheets by making a GET request to this URL:
https://spreadsheets.google.com/feeds/spreadsheets/private/full
See Google Spreadsheets API for more details:
http://code.google.com/apis/spreadsheets/data/3.0/developers_guide_protocol.html#ListingSpreadsheets
Related
Using API to get access_token and now I need to open Google Sheet.
Step 1.
Authorization: Bearer ya29.a0AV...." together with link: "https://docs.google.com/spreadsheets/u/0/d/[DocumentFileID]/edit"
Step 2.
Now HTML document back (~200kb). I'm using libcurl for that.
The problem is - missing are some css and js files and I see document just partially. Is there any way to open/edit Google Sheet using API?
I know for the option to just open https://docs.google.com/spreadsheets/u/0/d/[DocumentFileID]/edit in the new browser tab, but in that case I need to manually login to Google and that's what I try to avoid, because I want to use API to login and to open/edit a Sheet.
I also know for the option to share a document but I also try to avoid that. I'm writing application to customers who can access they own documents once they confirmed API usage.
I think you may have misunderstood what the google sheets api can do
The Google Sheets API is a RESTful interface that lets you read and modify a spreadsheet's data.
It gives you access to the data, it does not allow you to open the google sheets web application. Your going to have to code your own google sheets type app if you want users to open sheets directly.
I have a script that takes rows from a spreadsheet, and creates individual spreadsheet files for each row. Then the script publishes them to the web.
What I'm not able to get is the id that will allow me to get an url for a web version of it.
A regular spreadsheet id looks like this:
1N8h00iN2L7aaUbI9TYRWioaZHjHNSc_vNucCbVADj1o
And a published to the web id looks like this:
2PACX-1vTPSkv4Rz7CqwabTTfxa3xcVF-Gzxu7IboLyLkfoShP2d3qdX8o0qdvk5d_nWZD2rq43E2LXmVAm5HI
(longer, and it starts with 2PACX-)
Anybody know how to?
Thanks in advance.
You want to retrieve URL from the web published spreadsheet using file ID. If my understanding is correct, how about this answer? Unfortunately, "publishedLink" cannot be retrieved by Drive API v3. "publishedLink" got to not be able to be used from Drive API v3. Furthermore now, Drive API v2 also cannot be used anymore. So it is required to create the link manually.
When the spreadsheet is published to Web, you retrieve URL like as follows.
https://docs.google.com/spreadsheets/d/e/2PACX-1vTPSkv4Rz7CqwabTTfxa3xcVF-Gzxu7IboLyLkfoShP2d3qdX8o0qdvk5d_nWZD2rq43E2LXmVAm5HI/pubhtml
When you want to use the URL using file ID, please use the following URL. You can use both URLs.
Pattern 1:
https://docs.google.com/spreadsheet/pub?key=### fileId ###
Pattern 2:
https://docs.google.com/spreadsheets/d/### fileId ###/pubhtml
If I misunderstand your question, I'm sorry.
I have a Python cron job that pulls urls from sheet1 and populates sheet2 with scraped data from each url. Sheet 2 consists of [url, title, body, image urls]
I have an Old Google Site where I manually take sheet2's contents and create a new post. I want to automate this.
Structurally speaking would Google Scripts be able to pull and publish this dynamically? Lets say every time Sheet2 is updated (or a set interval).
I've worked with gscripts but never touched Google Sites before today.
The answer is probably yes. Apps script can do this. You have a couple of options.
Old Google sites
Option 1
Embed an apps script into the site as an iframe and stream you posts in that.
Option 2
Use either a standalone apps script or one attached to the google site and update the site using the Google Sites API.
New Google sites
Currently there is no apps script API for the new google sites. But you can embed JS HTML etc as a frame in the new sites. You can even use CDN libraries. Which means you can pull data from your sheet using something like AJAX.
Custom built option
The Google Sites API can be accessed anywhere you can handle Oauth. This means you can update Google Site from server-side code or from any client if you can handle Oauth.
I have two Google Sheets (sheetA and sheetB) and I'd like to know if it is possible to use the following hyperlink on a cell in sheetA to capture "Ford" in a cell in sheetB.
=HYPERLINK("https://docs.google.com/spreadsheets/d/1KmT653Ec0xREBw7AQlhG2jLWuPdVSqnp0nuLtgwrnI0/edit#gid=990300781?make=Ford","Ford")
If it isn't possible using the GET Method to append the hyperlink in sheetA, do you know of another way to pass info via a hyperlink to a cell in a google sheets?
Thanks for your insight and assistance.
The hyperlink formula only inserts a hyperlink to be clicked by a user, it doesn't send any HTTP requests.
On the other hand, importXML, importHTML, importFeed, and importData functions do fetch certain kinds of data (XML/HTML, HTML tables/lists, RSS/Atom, and CSV, respectively).
But apparently, your goal is to fetch data from another Google spreadsheet. The primary tool for that is importrange, which does not perform GET requests but directly gets the requested data from another spreadsheet with a given key or URL.
My app accesses private Google spreadsheet documents on behalf of an authorized user. It seems that Google's API expects developers to first request a list of all the spreadsheet documents available to an authorized user before they can get at a particular spreadsheet's keys. I wanted to find a workaround to this, and eventually did by extracting the key parameter value from URLs spreadsheet URLs that look like this:
https://docs.google.com/spreadsheet/ccc?key={some long key here}&usp=drive_web#gid=0
It was simple enough to just break down the string to point where I could retrieve key's value fairly easy without the need of a regex.
Recently, though I don't know how recent, I notice URLs to newly created Google Drive spreadsheets come in this form:
https://docs.google.com/spreadsheets/d/{some long key here}/edit#gid=0
I was also able to extract the key from this URL string, but am just curious about the difference between the two URLs:
What is the significance between the two URLs.
Why does Google's API force devs to first get a list of all available docs, when a dev might just want to extract a key from a direct URL to a Google Drive spreadsheet doc.
Thanks!
Old style sheets
They work online only and limited to about 400,000 cells per spreadsheet.
Old style URL
https://docs.google.com/spreadsheet/ccc?key={some long key here}&usp=drive_web#gid=0
New style sheets
Released about mid Dec 2013
Works offline and (if I remember) up to 2,000,000 cells per spreadsheet.
https://docs.google.com/spreadsheets/d/{some long key here}/edit#gid=0
Spreadsheet KEY
I get the key using Google-apps-script, as described here:
Get the spreadsheet key that is in the URL. Not ss.getId()
Where are you getting the URL from? You shouldn't rely on specific URL formats, these are subject to change and not intended to be reliable. You should be able get just the id by specifying the "fields" parameter in your request. See https://developers.google.com/drive/v2/reference/files/list
Cloudward has solved this through Cloud Snippets. Here's two that may be of help, there are lots of others to explore as well.
Publish Simple List from Google Sheet:
https://snippets.cloudward.com/app_listing.espx?template_id=0d367025e8b5f402cd510905cade1d29&account_id=&cat_id=c478885bb325028151eaa9060422c67f
Publish Google Doc by ID:
https://snippets.cloudward.com/app_listing.espx?template_id=51925e7ed2166d7d83a8c32fa1ee88dd&account_id=
Hope this helps.
Bob